Search Unity

Physics2D.Simulate to predict trajectory with Effector2D?

Discussion in '2D' started by Mcg, Dec 1, 2018.

  1. Mcg

    Mcg

    Joined:
    Mar 28, 2012
    Posts:
    112
    Hi, I'm trying to predict the trajectory of a game object that will enter a point effector2d and am currently using Physics2D.Simulate to draw the trajectory path however it only takes into account the velocity that I have set and the point effector2d doesn't seem to be calculated.

    I'm currently using this code when in play mode, the documentation says it only predicts all physics components in edit mode is there a way to get this to work in play mode? (Though I've not tested if this is correct in edit mode yet)

    Code (CSharp):
    1.             for (int j = 0; j < InBetweenFrameSteps; j++)
    2.             {
    3.                 PreviewedObject2D.DrawLine(j + InBetweenFrameSteps * i);
    4.                 Physics2D.Simulate(TimeStep/InBetweenFrameSteps);
    5.             }