spot robot pog

This commit is contained in:
Amaan Shawkath
2021-06-12 18:42:55 +01:00
parent 80178a0120
commit 2e83830241
4 changed files with 618 additions and 0 deletions

40
Assets/SpotController.cs Normal file
View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpotController : MonoBehaviour
{
public GameObject sphere;
private float speed = 6f;
private float revSpeed = 5f;
private float moveInput;
private float turnInput;
private float turnSpeed = 50f;
private void Start()
{
sphere.transform.parent = null;
}
private void Update()
{
moveInput = Input.GetAxisRaw("Vertical");
turnInput = Input.GetAxisRaw("Horizontal");
moveInput *= moveInput > 0 ? speed : revSpeed;
;
float newRotation = turnInput * turnSpeed * Time.deltaTime * Input.GetAxisRaw("Vertical");
sphere.transform.Rotate(0, newRotation, 0, Space.Self);
transform.position = sphere.transform.position;
transform.rotation = sphere.transform.rotation;
}
private void LateUpdate()
{
sphere.transform.Translate(Vector3.forward * moveInput * Time.deltaTime, Space.Self);
}
}