# Plot rigidbody path simulating magnus effect

I am trying to create a method that will plot the path a rigidbody will take when simulating a magnus type effect with no gravity in Unity. I realize this approach is a drastic simplification to the magnus force but the result is working for my application. I am applying a force to the rigidbody in FixedUpdate but keeping the velocity magnitude constant. In the picture below the actual plot of the rigid body is the yellow line. The green line is currently what the is produced by the Plot method. What do I need to add/change in the Plot method so that it will plot the exact same path the rigidbody will take? Thanks!

Plot without normalizing movementStep

public class BallSimple : MonoBehaviour
{
public Vector3 m_StartingDirection = new Vector3(0f, 0f, 1f);
public float m_Speed = 5f;
public Vector3 m_ForceDirection = new Vector3(1f, 0f, 0f);
public float m_ForceMagnitude = 1f;
public int m_Steps = 400;
public Rigidbody m_Rigidbody;
public LineRenderer m_SimulationPathLineRenderer;
public LineRenderer m_RealPathLineRenderer;
private int m_RealPathPoints = 0;

void Start()
{
m_Rigidbody.velocity = m_Rigidbody.velocity.normalized * m_Speed;
m_SimulationPathLineRenderer.positionCount = m_Steps;
m_RealPathLineRenderer.positionCount = m_Steps;
Plot(transform.position, m_StartingDirection.normalized * m_Speed, m_Steps);
}

private void FixedUpdate()
{
m_Rigidbody.velocity = m_Rigidbody.velocity.normalized * m_Speed;

if (m_RealPathPoints < m_Steps)
{
m_RealPathLineRenderer.SetPosition(m_RealPathPoints, transform.position);
m_RealPathPoints++;
}
}

private void Plot(Vector3 pos, Vector3 velocity, int steps)
{
float timestep = Time.fixedDeltaTime / Physics.defaultSolverVelocityIterations;

Vector3 magnusMovement = m_ForceDirection.normalized * m_ForceMagnitude * timestep * timestep;
Vector3 movementStep = velocity.normalized * m_Speed * timestep;

for (int i = 0; i < steps; ++i)
{
movementStep += magnusMovement;
movementStep = movementStep.normalized * m_Speed * timestep;
pos += movementStep;
m_SimulationPathLineRenderer.SetPosition(i, pos);
}
}
}


• I notice that you normalize velocity every frame in your actual physics tick, but do not apply this normalization in your plotting loop. Why is that? Commented Apr 27, 2022 at 18:18
• Just an oversite on my part. I normalized the movementStep in the plot loop and then multiplying it by m_Speed * timestep. It is a more accurate projection but still overshooting the actual path Commented Apr 27, 2022 at 19:03
• Want to edit your post to show your more accurate projection? Commented Apr 27, 2022 at 19:10