Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8414777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:15:08+00:00 2026-06-10T01:15:08+00:00

Can someone explain why the rectangle doesn’t spin here? This is Lua code and

  • 0

Can someone explain why the rectangle doesn’t spin here? This is Lua code and I’m using Corona SDK.

That is, I’ve tried to set up a rectangle with it’s centre of mass off-center, and then apply a force to it in the middle, expecting it to spin as it’s center of mass is off….

display.setStatusBar( display.HiddenStatusBar )

-- Setup
local screenCenterX, screenCenterY =  display.contentWidth/2, display.contentHeight/2

-- Create Object
local myRect = display.newRect(0, 0, 30, 90)
myRect.strokeWidth = 2
myRect:setFillColor(140, 140, 140, 0)
myRect:setStrokeColor(180, 180, 180)
myRect:setReferencePoint(display.CenterReferencePoint)
myRect.x, myRect.y = screenCenterX, screenCenterY

-- Apply Physics
local physics = require("physics")
physics.start()
physics.setGravity(0,0)
physics.addBody( myRect, "kinimatic", { friction=0.5, bounce=0.1, radius = 45 } )

-- Redefine Centre of Mass (what I'm trying to get right)
myRect.xOrigin, myRect.yOrigin = screenCenterX, screenCenterY - 100

-- Replace myRect to the center as setting the xOrigin/yOrigin seems to have moved it
myRect.x, myRect.y = screenCenterX, screenCenterY

-- Apply Force
timer.performWithDelay(3000,
        function(event)
                myRect:applyForce(5,0,  screenCenterX, screenCenterY)
                -- WHY DOES THIS NOT SPIN THE OBJECT???
                -- Centre of gravity has been change so shouldn't it rotate now?   
                -- That is, trying to simulate applying a force to an object who's centre of mass is NOT in 
                -- the center, and then see it spin.
        end
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:15:10+00:00Added an answer on June 10, 2026 at 1:15 am

    The variables xOrigin and yOrigin are used only to move a object, those variables cannot affect physics at all, and they are not really a “origin” (they are the x/y position of a object in relation of the parent “x/yOrigin” variable).

    To do a unbalanced physics object, you need to do it with the shapes, so you will have to create two shapes (thus you cannot use automatic shapes, you will have to use polygon), with one of them being heavier than the other to simulate the off-center mass.

    For example a rectangle with 100 units in length, you make 50 units weight 1, and the other 50 units weight 2, the result would be the center being at x 75 more or less (my math may be wrong here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone explain why this code doesn't work? Intent i = new Intent(this.context, SomeClass.class);
can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can someone explain what this ajax code does? function ajaxProgress(){ //Math.random() is for bitchy
Can someone explain to me why this code prints 14? I was just asked
can someone explain me the compilation error in this code: #include common.h typedef struct
Can someone explain the last line of this Python code snippet to me? Cell
Can someone explain this simple, yet deceiving, anomaly? There are two models, where B
Can someone explain me why this works: select val1, val2, count(case when table2.someID in
Can someone explain why, in this situation, scandir is getting my directory, but the
Can someone explain step by step how this query is processed? SELECT F.ID, F.FirstName,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.