Function OnDrawGizmosSelected: void Description. Implement this OnDrawGizmosSelected if you want to draw gizmos only if the object is selected. Gizmos are drawn only when the object is selected. Gizmos are not pickable. This is used to ease setup. For example an explosion script could draw a sphere showing the explosion radius. You can only use methods for gizmo drawing in OnDrawGizmos or in OnDrawGizmosSelected. You always want the path to draw, so you implement OnDrawGizmos. You set the color for the gizmo's drawing. Every draw call will use this color until you change it.
Ondrawgizmosselected Not Working
Jul 9th, 2020
Never
Not a member of Pastebin yet?Sign Up, it unlocks many cool features!
- usingPathfinding;
- publicclass EnemyAI : MonoBehaviour
- public Transform graphics;
- publicfloat speed = 1.2f;
- publicfloat aggroRange;
- Path path;
- bool reachedEndOfPath;
- Seeker seeker;
- {
- Gizmos.DrawWireSphere(transform.position, aggroRange);
- {
- target = GameObject.FindWithTag('Player').transform;
- rb = GetComponent<Rigidbody2D>();
- {
- }
- void FixedUpdate()
- if(path null)
- {
- return;
- else
- reachedEndOfPath =false;
- Vector2 direction =((Vector2)path.vectorPath[currentWaypoint]- rb.position).normalized;
- Vector2 force = direction * speed * Time.deltaTime;
- rb.MovePosition(rb.position+ force);
- float distance = Vector2.Distance(rb.position, path.vectorPath[currentWaypoint]);
- if(distance < nextWaypointDistance)
- currentWaypoint++;
- {
- }
- {
- }
- {
- float dist = Vector2.Distance(rb.position, target.position);
- if(dist <= aggroRange)
- InvokeRepeating('UpdatePath', 0, .5f);
- else
- CancelInvoke('UpdatePath');
- }
- {
- seeker.StartPath(rb.position, target.position, OnPathComplete);
- {
- {
- currentWaypoint =0;
- }
Ondrawgizmosselected Unity
RAW Paste Data