I am making a paper toss kind of game in Unity3d. I am implementing wind effect using constant force. I wanted to know how to make object fall in line with the target ie, if the object gets over the target, it should go in or fall in line with the target, not go behind or in front of the target. At present when I swipe applying a constant force, for different angles of swipe the distance moved by the object differs. Help would be much appreciated.
Share
In
FixedUpdate, usePhysics.Raycastto check to see if the object is over the target. If so, set the x and z values ofrigidbody.velocityto be zero (assuming y is the up/down axis in your game world) and disable theConstantForcecomponent (i.e.gameObject.GetComponent<ConstantForce>().enabled = false). Note that this won’t be most realistic of movements, as it will seem like the object suddenly moves straight down when it goes over the target — but it sounds like that’s what you want.