Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PlayerController : MonoBehaviour
- {
- public float moveSpeed = 5;
- public float jumpHeight = 100;
- public Rigidbody2D rigidBody;
- // Use this for initialization
- void Start()
- {
- rigidBody = GetComponent<Rigidbody2D>();
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f)
- {
- transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
- }
- if (Input.GetKeyDown(KeyCode.W))
- {
- rigidBody.AddForce(new Vector2(0, jumpHeight));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement