Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Calculate Initial/Launch Velocity

Discussion in 'Physics' started by ajitrko7, Dec 14, 2022.

  1. ajitrko7

    ajitrko7

    Joined:
    Mar 25, 2020
    Posts:
    4
    Hi All,

    I have one doubt in physics part in unity. Is it possible to calculate initial velocity of the object before it launches by using height, acceleration, displacement ?

    User giving the force and angle manually by dragging and goes up and down. The ball/bomb doesn't launch from Cannon. Once Player release the mouse it instantiate the bomb and get the velocity by using rigidbody.velocity. Is it possible to calculate before it instantiate the bomb? I hope there must be the some physics bowl hidden in unity to calculate before it launches.

    If you can help me on that, it would be really helpful for me :)

    upload_2022-12-15_0-19-8.png


    Please feel to ask any questions/ need detailed explanation on this part.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,434
  3. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    177
    I dont get your question to be honest. What is the goal?
     
  4. ajitrko7

    ajitrko7

    Joined:
    Mar 25, 2020
    Posts:
    4
    I need to calculate my velocity before bomb launches.
     
  5. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    177
    to do what? Do you want to predict the path it will go, or generate the force so that the ball has a certain velocity?

    The former can be just written as myRigidBody.AddForce(yourVelocity, ForceMode.VelocityChange);
     
    Last edited: Dec 16, 2022
  6. ajitrko7

    ajitrko7

    Joined:
    Mar 25, 2020
    Posts:
    4
    I want to predict my bomb velocity before it launches
     
  7. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    177
    Velocity = acceleration * deltaTime + OldVelocity. Acceleration = force/mass
     
  8. ajitrko7

    ajitrko7

    Joined:
    Mar 25, 2020
    Posts:
    4
    Okay, let me try this .. What meant by old velocity?
     
  9. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    177
    zero vector
     
  10. AshwinMods

    AshwinMods

    Joined:
    Jul 1, 2014
    Posts:
    12
    @ajitrko7 Calculating launch velocity is pretty easy once you learn about "projectile in motion".
    If you haven't solved it all already,
    Here is a small step-by-step guide that explains how to do it, I hope you find this helpful.

     
    GamerLordMat likes this.