Gravityscale vs physics.setGravity

As I understand it gravityscale affects the gravity of the physics object it is used on and physics.setGravity changes the gravity for all objects in the world/scene. Does anyone know which of these functions is less cpu intensive?

What do you mean?  Are you considering making multiple calls to setGravity()?

You need to give us more context.  How many objects are you modifying?  

Also, gravityScale is a field not a function.  It changes how a single object’s gravity response is calculated.  It cost nothing to change it except the cost of an assignment.

setGravity() is a function(), so the cost of using it is a function lookup, plus any side-effects of calling the function.  I imagine this may change the state of the physics system, so it could be relatively costly.

In any case w/o context this is all moot.  

How often are you going to modify gravity (once a second, once a frame, …) and how many objects are involved (10, 100, 1000…)?

objects present on screen when calling setGravity() less than 10

gravity will be changed once every 15 seconds.

So I guess my questions changes now since it seems to me that gravityScale does not “make” the object move but only changes that particular objects rate of movement relevant to the gravity already set. ex.) if the gravity was set to (10, 0) and I create an object with a gravityScale of 2 then it will move at a rate of (20, 0) or twice as fast does this sound right?

If you do this:

physics.setGravity( 0, 10 ) ... obj.gravityScale = 2 

‘obj’ will be acted on by a force of < 0, 20 >.  

You’re mixing up terms, which tells me you may not have formal training including physics (i.e. Have not taken a course in physics yet)?  If so, this is a summary:

Gravity is not a rate.  It is a force.  

Forces accelerate objects with mass.  

Acceleration is a change in rate and is proportional to the inverse square of time in seconds.

i.e. In the real world, the force of gravity is ~9.8 newtons.  This force accelerates objects at a rate of 9.8 meters/second^2

If an object falls under the force of gravity, it will be in these positions over time:

  • 0 seconds @ x
  • 1 second @ x - ~4.9 meters moving at a rate of ~9.8 m/s
    • ( this is the point where magnitude of velocity = magnitude of acceleration )
  • sqrt(2) seconds @ x - ~9.8 meters
    • ( this is the point where magnitude of distance travelled = magnitude of acceleration )
  • 2 seconds @ x - ~19.6 meters moving at a rate of ~19.6 m/s
    • ( this is the point where magnitude of distance travelled = magnitude of velocity )
  • 3 seconds @ x - ~44 meters moving at a rate of ~29.37 m/s
  • 14 seconds  @ x - ~960 meters moving at a rate of ~137 m/s

Tip: Physics acceleration in Corona has no unit, but I tend to think in terms of pixels per second for velocity, which equates to pixels/s^2 for acceleration.

Okay you confirmed what I just stated above and when I used rate I was referring to an increased rate of acceleration of the object in question… Also I would not confidently describe gravity as just a force. According to GR(General Relativity Theory) I would simply describe force as a push or pull. ex.) Drop a ball and a feather and they will hit the ground at the same rate of acceleration if no air resistance is present, but due to air resistance the feather floats while the ball which has more mass energy is able to over come the resistance and physically hit the ground first.

Remember Acceleration is the ratio of velocity change to time between any two points in an object’s path. To accelerate at 9.8 m/s/s means to change the velocity by 9.8 m/s each second.

Gravity is a curvature of space and time created by an objects mass… *Hmm* without getting to long winded and explaining I’ll just leave a few links if you’re interested in brushing up your physics. Thank you for helping me to better understand the use of gravityScale though  :slight_smile:

http://www.universetoday.com/108740/how-we-know-gravity-is-not-just-a-force/

http://curious.astro.cornell.edu/physics/140-physics/the-theory-of-relativity/general-relativity/1059-if-gravity-isn-t-a-force-how-does-it-accelerate-objects-advanced

If you were offended in some way, apologies.  I’m used to seeing a lot of new folks come in here missing some piece of fundamental training or experience.  i.e. Running before learning to walk.   You seemed to be mixing terms so I assumed that might be the case here.  

Regardless, thanks for the links, but I don’t need a refresher. 

What do you mean?  Are you considering making multiple calls to setGravity()?

You need to give us more context.  How many objects are you modifying?  

Also, gravityScale is a field not a function.  It changes how a single object’s gravity response is calculated.  It cost nothing to change it except the cost of an assignment.

setGravity() is a function(), so the cost of using it is a function lookup, plus any side-effects of calling the function.  I imagine this may change the state of the physics system, so it could be relatively costly.

In any case w/o context this is all moot.  

How often are you going to modify gravity (once a second, once a frame, …) and how many objects are involved (10, 100, 1000…)?

objects present on screen when calling setGravity() less than 10

gravity will be changed once every 15 seconds.

So I guess my questions changes now since it seems to me that gravityScale does not “make” the object move but only changes that particular objects rate of movement relevant to the gravity already set. ex.) if the gravity was set to (10, 0) and I create an object with a gravityScale of 2 then it will move at a rate of (20, 0) or twice as fast does this sound right?

If you do this:

physics.setGravity( 0, 10 ) ... obj.gravityScale = 2&nbsp;

‘obj’ will be acted on by a force of < 0, 20 >.  

You’re mixing up terms, which tells me you may not have formal training including physics (i.e. Have not taken a course in physics yet)?  If so, this is a summary:

Gravity is not a rate.  It is a force.  

Forces accelerate objects with mass.  

Acceleration is a change in rate and is proportional to the inverse square of time in seconds.

i.e. In the real world, the force of gravity is ~9.8 newtons.  This force accelerates objects at a rate of 9.8 meters/second^2

If an object falls under the force of gravity, it will be in these positions over time:

  • 0 seconds @ x
  • 1 second @ x - ~4.9 meters moving at a rate of ~9.8 m/s
    • ( this is the point where magnitude of velocity = magnitude of acceleration )
  • sqrt(2) seconds @ x - ~9.8 meters
    • ( this is the point where magnitude of distance travelled = magnitude of acceleration )
  • 2 seconds @ x - ~19.6 meters moving at a rate of ~19.6 m/s
    • ( this is the point where magnitude of distance travelled = magnitude of velocity )
  • 3 seconds @ x - ~44 meters moving at a rate of ~29.37 m/s
  • 14 seconds  @ x - ~960 meters moving at a rate of ~137 m/s

Tip: Physics acceleration in Corona has no unit, but I tend to think in terms of pixels per second for velocity, which equates to pixels/s^2 for acceleration.

Okay you confirmed what I just stated above and when I used rate I was referring to an increased rate of acceleration of the object in question… Also I would not confidently describe gravity as just a force. According to GR(General Relativity Theory) I would simply describe force as a push or pull. ex.) Drop a ball and a feather and they will hit the ground at the same rate of acceleration if no air resistance is present, but due to air resistance the feather floats while the ball which has more mass energy is able to over come the resistance and physically hit the ground first.

Remember Acceleration is the ratio of velocity change to time between any two points in an object’s path. To accelerate at 9.8 m/s/s means to change the velocity by 9.8 m/s each second.

Gravity is a curvature of space and time created by an objects mass… *Hmm* without getting to long winded and explaining I’ll just leave a few links if you’re interested in brushing up your physics. Thank you for helping me to better understand the use of gravityScale though  :slight_smile:

http://www.universetoday.com/108740/how-we-know-gravity-is-not-just-a-force/

http://curious.astro.cornell.edu/physics/140-physics/the-theory-of-relativity/general-relativity/1059-if-gravity-isn-t-a-force-how-does-it-accelerate-objects-advanced

If you were offended in some way, apologies.  I’m used to seeing a lot of new folks come in here missing some piece of fundamental training or experience.  i.e. Running before learning to walk.   You seemed to be mixing terms so I assumed that might be the case here.  

Regardless, thanks for the links, but I don’t need a refresher.