forked from Wireline-Studios/JourneyProject
Rocket Go NEOM
This commit is contained in:
BIN
Assets/Scenes/Scene1-Boss.unity
LFS
BIN
Assets/Scenes/Scene1-Boss.unity
LFS
Binary file not shown.
39
Assets/Scripts/Rocket.cs
Normal file
39
Assets/Scripts/Rocket.cs
Normal file
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Rocket.cs.meta
Normal file
2
Assets/Scripts/Rocket.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fc567df950c9c44c2a3ada34152072e4
|
||||||
Reference in New Issue
Block a user