- Home /
Applying force with respect to angle with the ground?
Hello,
I have a cube which is falling freely towards the ground. The cube right now has random rotation across X & Z axis (as it falls) and it does not have any rotations with Y axis. The cube is falling towards Y axis. Now in layman terms, if the cube is slanting, I would like to apply force in order to make the cube fall faster. Hence I thought I could just take the angle and apply relative force towards the direction it is turned.
Is that a good idea? If so could you guys help me with the logic and some pseudocode?
Thank you,
regards,
Karsnen.
puzzling, but interesting. How about : Raycast down, get the ray's hit normal, use that to modify the force being applied.
or if you want it to fall faster but in the same direction as gravity, just apply force straight down.
cannot figure out slanting if the cube is in constant rotation, or do you mean like the cube faces are affected by wind? puzzling ....
Edit : sry, I did take free-falling to include constant rotation. Am still a little lost on apply a little force when it is slanting too much . If you want it to fall faster depending on surface friction and wind resistance, it is still falling as per gravity, so apply force straight down. Or do you want to apply the force in the direction that a certain face or vertex is facing (to correct the angle of slant, or push in a certain direction based on face/vert)?
The cube is not in a constant rotation. The cube has it's own rotation but never a 360 across X or Z. I would like to say that it has a positive sinusoidal wave. Hence I would like to apply a little force when it is slanting too much. With raycast down, I hope you could do that but times when the cube gets perpendicular to the ground is very $$anonymous$$imal. It will never get really perpendicular.
I hope I am clear with what I have said.
Answer by Solus · Jul 04, 2012 at 06:10 PM
I'm not 100% sure what you're asking but this puts me in the mind of an asteroid entering orbit. Certain rotations of the asteroid may have less air resistance and fall faster and whatnot. If I understand you correctly you are looking for something like this:
if(BoxIsRotated) { Make Box Fall Faster; }
If that is the case you might be looking for something like this:
gameObject.rigidbody.AddForce(new Vector3(0, -1, 0) , ForceMode.Acceleration);
You would need a rigidbody on your cube and would probably need to adjust the Vector3 for your game scale and needs. You could also play around with different ForceModes.