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?
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.