-2
\$\begingroup\$

I have a character already in the game files and just need to know how he can move I have looked online in lots of places and it just doesn't make sense to me as I am sorta new to the game development scene please help. I think you can use C# or Javascript in Unity.

\$\endgroup\$
  • \$\begingroup\$ You can use the Input Manager to map W & S to the "Vertical" input and A & D to the "Horizontal" — when you create a new project these will already be configured by default. Have you tried this and run into any particular difficulty we can help with? \$\endgroup\$ – DMGregory Mar 13 '17 at 18:52
  • \$\begingroup\$ @DMGregory I cannot find the input manager can you tell me where to find it? \$\endgroup\$ – jonathan connery Mar 13 '17 at 18:56
  • 1
    \$\begingroup\$ This will sound rude, and I apologize for that. But you can find it with Google. If you want to make progress at any reasonable speed, you're going to have to learn to find these sorts of basic things on your own. \$\endgroup\$ – Almo Mar 13 '17 at 18:59
  • 1
    \$\begingroup\$ Geee, if only the very same document's parent page told you to find it in the Edit menu under Project Settings... ;) \$\endgroup\$ – DMGregory Mar 13 '17 at 19:19
  • 1
    \$\begingroup\$ I'm not going to spoon-feed you the documentation point-by-point. You'll have to show at least a little research effort of your own. If you still need help, that's fine, but you'll get enough knowledge to ask a specific focused question. If you hit a roadblock, describe in detail what you're trying to do and what's not working. \$\endgroup\$ – DMGregory Mar 13 '17 at 19:46
0
\$\begingroup\$

Here is the C# code you can use to make your character move using the W, A, S, D keys

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movement : MonoBehaviour {

public float speed = 1f;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    if (Input.GetKey(KeyCode.D))
        transform.position += new Vector3(speed * Time.deltaTime, 0.0f, 0.0f);

    if (Input.GetKey(KeyCode.A))
        transform.position -= new Vector3(speed * Time.deltaTime, 0.0f, 0.0f);

    if (Input.GetKey(KeyCode.W))
        transform.position += new Vector3(0.0f, speed * Time.deltaTime, 0.0f);

    if (Input.GetKey(KeyCode.S))
        transform.position -= new Vector3(0.0f, speed * Time.deltaTime, 0.0f);
}
}
\$\endgroup\$
  • \$\begingroup\$ @user6668201 I don't know what you mean I just looked up a YouTube tutorial for 2D W, A, S, D controls and this came up \$\endgroup\$ – jonathan connery Mar 14 '17 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.