DSIK_project/ShooterDSIK_newbac/Assets/Scripts/PlayerMovement.cs
Konrad Pierzyński e1234ad7c0 Added Unity Client
2018-11-29 17:20:24 +01:00

36 lines
918 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
Rigidbody rb;
public float speed = 10f;
public bool active = true;
void Start () {
rb = GetComponent<Rigidbody>();
}
void Update () {
if( active )
{
if (Input.GetKey(KeyCode.UpArrow))
{
rb.AddForce(new Vector3(1, 0, 0) * speed);
}
if (Input.GetKey(KeyCode.DownArrow))
{
rb.AddForce(new Vector3(-1, 0, 0) * speed);
}
if (Input.GetKey(KeyCode.LeftArrow))
{
rb.AddForce(new Vector3(0, 0, 1) * speed);
}
if (Input.GetKey(KeyCode.RightArrow))
{
rb.AddForce(new Vector3(0, 0, -1) * speed);
}
}
}
}