From 3c743071c0f55955cee6f88637d853622065bb5c Mon Sep 17 00:00:00 2001 From: Garrett Kaiser Date: Tue, 20 Jan 2026 15:34:36 -0800 Subject: [PATCH] Rocket Go NEOM --- Assets/Scenes/Scene1-Boss.unity | 4 ++-- Assets/Scripts/Rocket.cs | 39 +++++++++++++++++++++++++++++++++ Assets/Scripts/Rocket.cs.meta | 2 ++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 Assets/Scripts/Rocket.cs create mode 100644 Assets/Scripts/Rocket.cs.meta diff --git a/Assets/Scenes/Scene1-Boss.unity b/Assets/Scenes/Scene1-Boss.unity index 2f5ef5e..32527ed 100644 --- a/Assets/Scenes/Scene1-Boss.unity +++ b/Assets/Scenes/Scene1-Boss.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40a24a59108b9678a975624f64bada902594b30927f92076f81dd47a74b83d77 -size 1283556 +oid sha256:85c43a16033d8971968c7b9a0e9e6b6b4bdbdb7037fd7962fc3591b445637365 +size 1290319 diff --git a/Assets/Scripts/Rocket.cs b/Assets/Scripts/Rocket.cs new file mode 100644 index 0000000..89b65bd --- /dev/null +++ b/Assets/Scripts/Rocket.cs @@ -0,0 +1,39 @@ +using UnityEngine; + +public class Rocket : MonoBehaviour +{ + public GameObject player; + public Vector3 TargetPosition; + public float playerDistance; + + public Vector3 direction; + public Quaternion targetRotation; + public float rotationSpeed = 30; + + public bool isStuck; + public float despawnTimer = 10; + // Start is called once before the first execution of Update after the MonoBehaviour is created + void Start() + { + player = GameObject.Find("Player"); + TargetPosition = player.transform.position; + } + + // Update is called once per frame + void Update() + { + if (playerDistance >= 25) + { + rotationSpeed = 60; + } + else{ + rotationSpeed = 30; + } + direction = (player.transform.position - transform.position).normalized; + targetRotation = Quaternion.LookRotation(direction); + transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, 30 * Time.deltaTime); + + playerDistance = Vector3.Distance(transform.position, player.transform.position); + transform.Translate(Vector3.forward * Time.deltaTime * (playerDistance/2+3)); + } +} diff --git a/Assets/Scripts/Rocket.cs.meta b/Assets/Scripts/Rocket.cs.meta new file mode 100644 index 0000000..5ada517 --- /dev/null +++ b/Assets/Scripts/Rocket.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: fc567df950c9c44c2a3ada34152072e4 \ No newline at end of file