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. Dismiss Notice

Question How to make player(rocket) controller.

Discussion in 'Scripting' started by PanPrezess, Sep 20, 2020.

  1. PanPrezess

    PanPrezess

    Joined:
    Aug 17, 2020
    Posts:
    8
    How to make a rocket controller that will work like that:

    D & A - Rocket rotation

    W - move forward

    I want to move the rocket towards its tip when pressing w.


    Thanks in advance!
    (sorry for this newbie question)
     
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    Hey there,

    well you need to try it by yourself somehow,
    if you got any issues you can post them here obv. and people will try to help,

    i just want to say, dont expect someone coming up with a chunk of code which will
    work out of the box :)

    To your issue: Get on a Movement Tutorial (there are many out there) and try to modify it , most Tutorials will cover 70% of your desired Behaviour =)
     
    PanPrezess and eses like this.
  3. rubcc95

    rubcc95

    Joined:
    Dec 27, 2019
    Posts:
    222
    I'm agree with Terraya, there's a bunch of tutorials at net in order to make dat... Just some tips:

    If you're using a RigidBody or Rigidbody2D:

    transform.rotation * Vector2.up (2D) or transform.rotation * Vector3.forward (3D) gives you the normalized Vector3 pointing in your GameObject direction... dats usefull for add a force in the direction rocket is pointing.

    Rigidbody2D.AddTorque() rotates the object.
     
    PanPrezess likes this.
  4. PanPrezess

    PanPrezess

    Joined:
    Aug 17, 2020
    Posts:
    8
    thanks