TheKingsRace/Assets/Scripts/KingScripts/KingMove.cs
Katherine f20dbd6032 Implemented Hail and reoganised Abilities
>Hail is spawned at a rondom spot in an area
>Hail creates a Shadow directly underneath it
>Hail falls, and shadow scales to the correct size
>Abilites moved into their own folder
>King Implementation Scene Created and King Movement Created
2021-11-17 12:27:35 -06:00

41 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KingMove : MonoBehaviour
{
public float speed = 30.0f;
public float rotSpeed = 30.0f;
private Vector3 newPos;
// Update is called once per frame
void Update() {
float translation = Input.GetAxis("HorizontalCam") * speed;
float rotation = Input.GetAxis("HorizontalCam") * rotSpeed;
// Make it move 10 meters per second instead of 10 meters per frame...
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
// Move translation along the object's z-axis
if (transform.position.z <= 61 && transform.position.z >= -80) {
transform.Translate(0, 0, -translation);//Is negated to make the Left arrow go left and the right arraow go right
transform.rotation = Quaternion.Euler(0, 0, 0);
}
else if (transform.position.z > 61) {
transform.position = new Vector3(-42, 30, 61);//Keeps them from going too far left
}
else if (transform.position.z < -80) {//Once they rech a certain point they begin to cirlce around the mountain (radius of 42, x^2+z^2=42^2)
transform.Rotate(0, -rotation, 0);// Rotates the player as they move along the circumfurance
float z = transform.position.z - 0.5f;
float x = Mathf.Sqrt((42 * 42) - ((z + 80) * (z + 80)));//Add something based off translation to X and calculate the corespondent Z Z = sqrt(42^2-x^2)-80
newPos = new Vector3(-x, 30, z); // make a Vector3 out of the new X and Z
transform.position = newPos;//Sets the player's new position on the cirlce
}
else {
Debug.Log("Aw, Beans");
transform.position = new Vector3(-42, 30, 0);
}
}
}