- Home /
Question by
DanielGL · Feb 06 at 03:29 PM ·
physicsrigidbodyforceprediction
Predicting land position with drag applied
i'm trying to predict the land position of a launched ball in a flat plane, (no obstacles or collisions to worry), so far I've reached in the following solution:
Vector3 landPos = Vector3.zero;
float yForce = direction.y * force;
float heightTime = yForce >= 0 ? yForce / (-Physics.gravity.y * physicBoddy.mass) : 0;
float maxHeight = physicBoddy.transform.position.y + yForce * heightTime + Physics.gravity.y * Mathf.Pow(heightTime, 2) / 2;
var qe = D_Math.QuadracticEquation(Physics.gravity.y / 2, yForce < 0 ? yForce : 0, maxHeight);
float fallTime = qe[0] > 0 ? qe[0] : qe[1];
float airTime = heightTime + fallTime;
float hFactor = force / physicBoddy.mass * airTime;
landPos.x = physicBoddy.transform.position.x + direction.x * hFactor;
landPos.z = physicBoddy.transform.position.z + direction.z * hFactor;
landPos.y = 0;
return landPos;
This solution works perfectly with any property of the Rigidboddy except the drag, I couldn't predict how it affects maxHeight and airTime, so if the drag isn't 0, the prediction fails. How can I add the drag to this prediction?
Comment
Your answer
Follow this Question
Related Questions
Direction of rotation and ApplyForce 1 Answer
AddRelativeTorque not rotating 1 Answer
Simple colliding objects are updated a frame late. 0 Answers
Shooting a cannonball. 6 Answers
Check if object is applying force to another object 0 Answers