- Home /
How to force physics
I'm trying to make a Halo forge style editor in which a player can place a cube by pressing the mouse button. I have sort of a "3d crosshair" that floats in front of the player to show where the cube will be placed. The crosshair cube follows my mouse using the Vector3.Lerp function. The problem is, when I move my mouse down towards the ground, my crosshair cube moves underground. I want it to instead use physics and stop above the ground until my mouse aims above ground again, at which point the crosshair cube continues to follow it. I have a collider on the cube and ground, but the Vector3.Lerp function seems to ignore physics. Does anybody have a fix/workaround?
Answer by Rush3fan · Jul 07, 2012 at 06:27 AM
You may need to use force instead. Setting the velocity of the RB may work too, but I have found that to look a lot more glitchy when your object does collide with other things. The trick is going to be getting your object to float using only forces. You don't want to have your object start oscillating randomly.
Oh.. here's another idea: You could play with attaching your crossair to the object using a joint. That might be easier.
Your answer
Follow this Question
Related Questions
Shooting a cannonball. 6 Answers
Direction of rotation and ApplyForce 1 Answer
How can I make a physics object jump a given height on collision regardless of current velocity? 1 Answer
Box2D force on object? 0 Answers
How to make thruster rotation 0 Answers