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’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Question Need Help

Discussion in 'Physics' started by PortalShibe77, May 20, 2023.

  1. PortalShibe77


    May 7, 2023
    I am trying to move a player along the three, world axis, so if I move in one direction it takes longer to change direction, or I can specifically add or remove speed to a specific direction.

    My problem however is that I have a vector called Player, and wrote this code to control it.
    Code (CSharp):
    1. Movement.x = XVelocity;
    2.       Movement.y = YVelocity;
    3.       Movement.z = ZVelcoity;
    5.       Player.Move(Movement * Time.deltaTime);
    so if i make Xvelocity 10, the character will move +10 along the X axis a set amount of times a second.
    if i then want to move back, and only add -5 to the XVelocity then it will mean that I'm still moving at +5 on the x-axis.
    The problem occurs because I want to make it when i press "W' for example, I add a number like 10 to the direction I'm going moving me forward, relative to the direction I'm looking, but if I'm looking between to axis, then I can only move them along the world axis meaning i cant move forward.

    Anyone please help/
    Last edited: May 20, 2023
  2. driftnumata


    May 31, 2023
    Is that only when you "W" key pressed?