5/16/2023 0 Comments Unity mkplayer addforce![]() If multiple sources/scripts AddForce to a Rigidbody, all of those effects get added together to create a net change in the object's movement (which, depending on how it's calculated, may also be order-independent). Because the player's actual hand is in a known place and didn't slow down from collision with that virtual object, their virtual hand needs to do the same to stay in alignment, so in this case we actually want to override all other physics effects to get it there.ĪddForce and similar helper functions, by contrast, are made to cooperate with everything else going on in the physics world. For example, when I'm making Kinect games and I want the player's virtual avatar's limbs to be able to interact with the physics scene, I usually move those bodies using direct velocity setting. This can lead to launching objects you collide with, or small objects being able to push huge ones much more easily than it seems like they should, or objects sliding slowly along static barriers instead of deflecting away/along them.īoth of these effects can be desired sometimes. It's as though your object is being propelled by an engine with infinite torque - no matter how much velocity it loses on an impact, it's back up to top speed on the very next physics step, and its velocity isn't deflected away from the impact. If you're setting velocity every frame, collisions with other objects can be a bit weird. This can lead to order of update bugs, in particular causing entities to hover or fall slowly (because downward acceleration due to gravity gets overridden before it can accumulate) body.velocity = foo), then whichever one runs last wins, and the others have zero effect. ![]() If multiple sources/scripts try to modify the same Rigidbody's velocity by setting it directly (ie. Just be wary, because when used in the wrong situations it can cause issues: In some situations this is desirable, such as setting the initial velocity of a bullet once at the moment it's fired, as in trojanfoe's example. When you set velocity, you're overriding absolutely everything else that might affect that object's movement. Although there's already an accepted answer, I think there are some additional details worth covering.
0 Comments
Leave a Reply. |