Hex_Tv
Hex_Tv
CC#
Created by Hex_Tv on 8/26/2023 in #help
❔ i have two errors in this code unity Turret code please help
errors - Assets\Code\Scripts\Turret.cs(46,32): error CS0103: The name 'instantiate' does not exist in the current context Assets\Code\Scripts\Turret.cs(46,91): error CS0117: 'Quaternion' does not contain a definition for 'Identity'
8 replies
CC#
Created by Hex_Tv on 8/26/2023 in #help
I have errors one unity turret script
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class Turret : MonoBehaviour { [Header("References")] [SerializeField] private Transform turretRotationPoint; [SerializeField] private LayerMask enemyMask; [Header("Attribute")] [SerializeField] private float targetingRange = 5f; private Transform target; private void Update() { if (target == null){ FindTarget(); return; } RotateTowardsTarget(); if (!CheckTargetIsInRange)(); { target = null; } } private void FindTarget() { RaycastHit2D[] hits = Physics2D.CircleCastAll(transform.position, targetingRange, (Vector2) transform.position, 0f, enemyMask); if (hits.Length > 0) { target = hits[0].transform; } } private bool CheckTargetIsInRange(); { return Vector2.Distance(target.position, transform.position) <= targetingRange; } private void RotateTowardsTarget() { float angle = Mathf.Atan2(target.position.y - transform.position.y, target.position.x - transform.position.x) * Mathf.Rad2Deg - 90f; Quaternion targetRotation = Quaternion.Euler(new Vector3(0f, 0f, angle)); turretRotationPoint.rotation = targetRotation; } private void OnDrawGizmoSelected() { Handles.color = Color.cyan; Handles.DrawWireDisc(transform.position, transform.forward, targetingRange); }
}
46 replies
CC#
Created by Hex_Tv on 8/26/2023 in #help
I have error in Unity EnemySpawner Script c#
16 replies