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 have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

C# Moving Player Without Input

Discussion in 'Scripting' started by chubchub5577, Oct 25, 2015.

  1. chubchub5577

    chubchub5577

    Joined:
    Jul 25, 2014
    Posts:
    2
    I want my player to move on the X and Y axis and change direction when you click on the screen anywhere. It should be simple but I can not think about getting it stated.
    All I want the code to do it...
    • Move the player toward the spawned sprite on either the X or Y plane
    • Constantly check if the player tapped the screen while in a box colider around the sprite
    • If yes spawn new sprite destroy old sprite change direction toward sprite
    • If no stop player go to 'gameover' scene
    I feel like itll be some sort of transform on the axis then just a while and an if statement. I am so lost and cannot think of what I need to start. Please help thank you very much!!!
     
    Last edited: Oct 25, 2015
  2. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    can the player move diagonally? Or just 1 axis at a time?
     
  3. chubchub5577

    chubchub5577

    Joined:
    Jul 25, 2014
    Posts:
    2
    Just one axis at a time its 2d i guess I didnt mention that and it is moving on a ground directly under it. Thanks for the reply let me know if you have any more questions