Files
az_tank_remake/3D/Assets/Scripts/PlayerMovement3d.cs

30 lines
786 B
C#
Raw Normal View History

2022-03-01 16:05:07 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement3d : MonoBehaviour
{
public float movespeed = 15f;
public Rigidbody rb;
2022-03-02 09:36:38 +01:00
public Vector3 movement;
public Vector3 rotation;
2022-03-02 07:02:41 +01:00
private float x, y;
2022-03-01 16:05:07 +01:00
void Update() {
//Input
x = Input.GetAxisRaw("Horizontal");
y = Input.GetAxisRaw("Vertical");
movement = new Vector3(0f, 0f, y);
rotation = new Vector3(0f, x, 0f);
}
void FixedUpdate() {
//Movement
rb.MovePosition(rb.position + movement * movespeed * Time.deltaTime);
//rb.AddForce(rb.position + movement * movespeed * Time.deltaTime);
rb.MoveRotation(rb.rotation * Quaternion.Euler(rotation.x, rotation.y, rotation.z));
}
}