Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Show where object to fall

Discussion in 'Scripting' started by Givago, Oct 16, 2017.

  1. Givago

    Givago

    Joined:
    Oct 22, 2015
    Posts:
    27
    I'm following this tutorial to create an arc in the game:

    https://en.wikipedia.org/wiki/Range_of_a_projectile

    I would like to show the trajectory using ADDFORCE, but...
    I do not know what the actual values to pass into the script, and this script just create a arc,he does not go to the floor, not taking into account the scene.

    Thanks.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    If you're using physics, then the physics will simulate it (i.e., discretely approximate an arc) at whatever your platform Time.fixedDeltaTime value is, over whatever time interval it is "flying."

    If you're doing it yourself all in one step to pre-generate the mesh arc, you can use your initial velocity, apply it incrementally at this time interval, and use also the current Physics.gravity setting to do all the work yourself in a single frame and use the values along the parabola to produce a mesh.

    In the latter case it does not make sense to use Rigidbody.AddForce() because that will have no effect until you allow the physics simulator to run. And in any case, Physics.gravity is automatically added to your Rigidbodies as long as they have "Uses Gravity" turned on.