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

Question How do I make my character move in the direction they are looking

Discussion in 'Visual Scripting' started by fiesinator, Mar 14, 2023.

  1. fiesinator

    fiesinator

    Joined:
    Oct 17, 2020
    Posts:
    1
    Basically title. I want to make a tank like control scheme for a player but cant define the direction it is looking at. When I use Character controller the rest of the movement from my character doesnt work anymore so I would like to do it with set velocity or force if thats possible.
     
  2. vintage-retro-indie_78

    vintage-retro-indie_78

    Joined:
    Mar 4, 2023
    Posts:
    285
    you need to calculate the forward-looking vector, one can do that based on rotation . . .

    Screenshot (5224).png

    then, just add that to the current position every frame, or use it for the velocity vector . . .

    Screenshot (5225).png

    the math to calculate the forward-movement vector is bit tricky, you need the cosine, and sine value, those are how to then make a forward-moving vector . . . . :) :eek: