Compare commits

..

2 Commits

Author SHA1 Message Date
Garrett Kaiser
50a5d8c527 Merge branch 'main' of https://git.wirelinestudios.com/Wireline-Studios/JourneyProject 2025-11-19 14:21:29 -08:00
Garrett Kaiser
a057798e3e GUN NO ROTATE :( 2025-11-17 15:30:29 -08:00
3 changed files with 27 additions and 5 deletions

View File

@@ -28,13 +28,13 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6611039685471789196} m_GameObject: {fileID: 6611039685471789196}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} m_LocalRotation: {x: 0.38268343, y: 0, z: 0, w: 0.92387956}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.4, y: 0.5, z: 0.4} m_LocalScale: {x: 0.4, y: 0.5, z: 0.4}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
--- !u!33 &5688607449888095492 --- !u!33 &5688607449888095492
MeshFilter: MeshFilter:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@@ -4,6 +4,12 @@ public class GunThrown : MonoBehaviour
{ {
public GameObject player; public GameObject player;
public Vector3 TargetPosition; public Vector3 TargetPosition;
public Vector3 targetDirection;
public Quaternion targetRotation;
public bool isStuck;
public float despawnTimer = 10;
// Start is called once before the first execution of Update after the MonoBehaviour is created // Start is called once before the first execution of Update after the MonoBehaviour is created
void Start() void Start()
{ {
@@ -14,12 +20,28 @@ public class GunThrown : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
transform.LookAt(player.transform);
transform.rotation = Quaternion.Euler(transform.rotation.x + 55, transform.rotation.y, transform.rotation.z);
transform.position = Vector3.MoveTowards(transform.position, TargetPosition, 10 * Time.deltaTime); transform.position = Vector3.MoveTowards(transform.position, TargetPosition, 10 * Time.deltaTime);
if (transform.position == TargetPosition)
{
isStuck = true;
}
if (isStuck)
{
despawnTimer -= Time.deltaTime;
if (despawnTimer <= 0)
{
Destroy(this.gameObject);
}
}
} }
private void OnCollisionEnter(Collision collision) private void OnCollisionStay(Collision collision)
{ {
if (collision.gameObject.tag == "Player") if (collision.gameObject.tag == "Player" && !isStuck)
{ {
Destroy(this.gameObject); Destroy(this.gameObject);
} }

View File

@@ -53,7 +53,7 @@ public class ThrowerEnemy : MonoBehaviour
playerDistance = Vector3.Distance(transform.position, target.position); playerDistance = Vector3.Distance(transform.position, target.position);
if (playerDistance < 25 && canThrow) if (playerDistance < 25 && canThrow)
{ {
Instantiate(GunThrow, transform); Instantiate(GunThrow, transform.position, Quaternion.identity);
canThrow = false; canThrow = false;
} }
} }