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

Resolved movement relative to rotation new input system visual scripting

Discussion in 'Visual Scripting' started by jkjkrules, Sep 15, 2022.

  1. jkjkrules

    jkjkrules

    Joined:
    Jan 2, 2016
    Posts:
    16
    I'm trying to add a way to move the character and rotate but when rotating the movement is still moving in the same direction so depending on what way you turn the movement is weird.
     

    Attached Files:

  2. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    few things I see with this.
    but to answer your question about movement, it's because you are only setting the velocity relative to the world. you're not taking it's current Hedding into account.

    Basically what you need is a forward vector to define what is forward, then you move the object along that forward vector by some value.

    But also, generally you'd want to use Move instead of set velocity also. But dono. depends on your game and what you're lookin' to do.


    Here we can see how TRANSFORM.GetForward is multiplied (with generic multiply) with the W Keypress before getting multiplied again by the sensitivity. Here I'm using Add Relative Force.

    Note that this does not do any delta time calculations to smooth movement independent of framerate

    Capture.PNG
     
    Last edited: Sep 16, 2022
    jkjkrules likes this.