Data Realms Fan Forums http://45.55.195.193/ |
|
How to use AddForce and whats the difference? http://45.55.195.193/viewtopic.php?f=73&t=16531 |
Page 1 of 1 |
Author: | numgun [ Tue Sep 15, 2009 11:06 am ] |
Post subject: | How to use AddForce and whats the difference? |
So I went to check for a function in the wiki to add force to an object, but the docs are pretty unclear whats the difference between the following: AddForce() AddAbsForce() AddImpulseForce() Whats the difference between these guys and how to use them right? For AddForce it said to define a vector, a value and another vector. I dont know why or how it works but doing it as it said in the docs didnt work. How do I use these? How am I supposed to write the statement for it. |
Author: | Kyred [ Wed Sep 16, 2009 5:13 am ] |
Post subject: | Re: How to use AddForce and whats the difference? |
I apologize in advance for the long winded reply. I haven't really done much with force on CC, but I know a few things about these functions. AddForce() applies a force to an object. By force, it means the force defined in Newtons Second Law: Force = mass * acceleration (or the rate of change of momentum with respect to time). This is measured in Newtons (N). 1 Newton is the force needed to accelerate a mass of 1 kilogram to 1 meter per second, within 1 second. In terms of units, that is: N = kg*m/(s^2). (m stands for meters, not mass). AddAbsForce() I believe is the same as AddForce() except it takes the absolute value of the force before applying it. AddImpulseForce(), however, is slightly different from the other two. Instead of appling a force, it applies an impulse. Impulse is measured in momentum, which is mass * velocity. For units, that's Momentum = kg * m/s. So when do you want to use Force vs. Impulse force? Use force when you want to effect an object's acceleration. However, I can't really think of a good example on how to use that at the moment. Impulse force is useful for collisions and explosions. Say you want to simulate two soldiers colliding into each other. To accurately exert an impulse from one soldier onto the other, simply multiply that soldiers mass by his velocity and stick it into the ImpulseForce function. Done. The game handles the rest of the algebra involved. I hope some of this helps. **The vector you supply to the functions is the location on the body to apply the force, so that the game can simulate torque and rotation. |
Author: | Geti [ Wed Sep 16, 2009 5:41 am ] |
Post subject: | Re: How to use AddForce and whats the difference? |
the best use of force i can see is for lua based rockets and stuff. |
Author: | numgun [ Wed Sep 16, 2009 7:54 am ] |
Post subject: | Re: How to use AddForce and whats the difference? |
My purpose is to make a head pop off the torso upwards. So I'm trying to use force to "detach" an attachable pretty much. One interesting thing I found in the Attachable class is the Detach() function, but this seems to completely delete the entire head instead of severing the link between its parent. My guess is that I'm supposed to use AddImpulseForce, but I'm not entirely sure how to build the statement. So is this one correct?: Code: head.AddImpulseForce(Vector(0,0),Vector(0,-30)); --The purpose is to make it go up. Hence the Y -30 value. |
Author: | Geti [ Wed Sep 16, 2009 9:26 am ] |
Post subject: | Re: How to use AddForce and whats the difference? |
reverse your vector's order. Impulse vector, then offset vector, in meters. oh also, now you're talking about Detach(), if you can, pester data about attachables that were attached with lua to something cause crashes if the thing they are attached to is removed from the scene (by gibbing or whatever else) before they are manually detached. putting detach in the Destroy() function of the object does ♥♥♥♥ all. |
Author: | ProjektTHOR [ Wed Sep 16, 2009 12:28 pm ] |
Post subject: | Re: How to use AddForce and whats the difference? |
I apologize if this is a noobish response, but why not use this Detach() function then use a wound emitter that emits the head sprite? I have no idea if that would even work, just offering an outside suggestion |
Author: | zalo [ Sat Sep 19, 2009 11:30 pm ] |
Post subject: | Re: How to use AddForce and whats the difference? |
Sorry for bumping 3 day old thread, but negative jointstrength works great for popping things off. |
Author: | numgun [ Sun Sep 20, 2009 7:08 am ] |
Post subject: | Re: How to use AddForce and whats the difference? |
Hey nice, I can even balance it more clearly with jointstrength than addforce, thanks Zalo! |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |