Search Unity

How to use reall physics with a rocket?

Discussion in 'Scripting' started by piluve, Feb 3, 2013.

  1. piluve

    piluve

    Joined:
    Mar 17, 2012
    Posts:
    158
    Hello;

    I´m working on a mini project, what i want to do is to make a spatial aeromodelling simulator, so it have to work with real physics...

    What i want to know is how do i add a force that propulsate the rocket?And how i can implement i timer for the engine (3 secs and stop..)?

    All this further respecting the laws of physics for more realism.
    I was thinking in use addForce
    Code (csharp):
    1.     rigidbody.AddForce (0, 10, 0);
    Here a capture.. :)


    See you!
    Thx!
     
    Last edited: Feb 3, 2013
  2. Gamer'sHelmet

    Gamer'sHelmet

    Joined:
    Oct 24, 2012
    Posts:
    49
    you could have a delta timer that counts to 4 and a loop that says to addforce up while the timer is lessthan or equal to three
     
  3. piluve

    piluve

    Joined:
    Mar 17, 2012
    Posts:
    158
    Yeah it will works because at the moment, i applied the add force when you press launch so these " initial" force is huge so it will be nice to add the force gradually....

    Any idea on how to implement the timer?

    See you
    Thx!
     
    Last edited: Feb 3, 2013
  4. piluve

    piluve

    Joined:
    Mar 17, 2012
    Posts:
    158
    Anyone?
     
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Youre in trouble if you cant figure out a simple timer while trying to implement physics.. theres also plenty of articles on google for this sort of thing.

    Code (csharp):
    1.  
    2.  
    3. float timer=0;
    4. void FixedUpdate() {
    5.  timer += time.deltaTime;  
    6.  if(timer < 4)
    7.    rigidbody.addforce(...
    8. }
    9.  
    10.