3 Replies - 1599 Views - Last Post: 24 February 2013 - 09:15 AM Rate Topic: -----

#1 NoSoulNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-February 13

Unity C# keyboard input

Posted 24 February 2013 - 04:39 AM

Hi all im new to this forum so i hope this is in the correct place.

Im trying to teach myself unity at the moment and i want to make a small 2D sidescroller in C# rather then javascript. Ive already done a few tutorials in XNA and i was just wondering how would i make a object to move with the keyboard?

I already know in XNA its
private void handleKeyboardInput(KeyboardState keyState)
{
    if(keyState.IsKeyDown(Keys.up))
    {
        playerSprite.Velocity += new Vector2(0. -1);
    }
}



and in unity javascript its something like this
function Update()
{
    if(Input.GetKey(KeyCode.UpArrpw))
    {
        currentState = shipState.MOVINGUP;
        ActionShip(currentState);
    }
}



Can anyone give me some tips because im a bit unsure on what to do?

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Unity C# keyboard input

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Unity C# keyboard input

Posted 24 February 2013 - 08:44 AM

What are you unsure of? How do you want things to move?
Was This Post Helpful? 0
  • +
  • -

#3 NoSoulNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-February 13

Re: Unity C# keyboard input

Posted 24 February 2013 - 09:09 AM

Im just unsure on the code. I want the player to move with input from the keyboard but i just need some help with the code for it?
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3462
  • View blog
  • Posts: 11,727
  • Joined: 12-December 12

Re: Unity C# keyboard input

Posted 24 February 2013 - 09:15 AM

I know nothing about Unity Javascript, but I know that it is UpArrow.

http://docs.unity3d....put.GetKey.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1