Files
az_tank_remake/Assets/Scripts/PlayerMovement.cs

26 lines
557 B
C#
Raw Normal View History

2022-02-24 12:56:25 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float movespeed = 5f;
2022-02-28 10:00:00 +01:00
public Rigidbody rb;
Vector3 movement;
2022-02-24 12:56:25 +01:00
// Update is called once per frame
2022-02-28 10:00:00 +01:00
2022-02-24 12:56:25 +01:00
void Update()
{
//Input
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
2022-02-28 10:00:00 +01:00
movement.z = 0;
2022-02-24 12:56:25 +01:00
}
void FixedUpdate() {
//Movement
rb.MovePosition(rb.position + movement * movespeed * Time.fixedDeltaTime);
}
}