Day 69 — Implementing a Coin Distraction Ability Part 2

void SendAIToCoin(Vector3 coinPos)
{
GameObject[] guards = GameObject.FindGameObjectsWithTag("Guard1");
foreach(var guard in guards)
{
NavMeshAgent currentAgent = guard.GetComponent<NavMeshAgent>();
GuardAI currentGuard = guard.GetComponent<GuardAI>();
Animator guardAnim = guard.GetComponent<Animator>();

currentGuard.coinThrown = true;
currentAgent.SetDestination(coinPos);
guardAnim.SetBool("Walking", true);
currentGuard.coinPos = coinPos;
}
}
public bool coinThrown;
public Vector3 coinPos;
if (wayPoints.Count > 0 && wayPoints[_currentTarget] != null && coinThrown == false)
{
}else
{
float distance = Vector3.Distance(transform.position, coinPos);
if (distance < 4f)
{
_anim.SetBool("Walking", false);
}
}

--

--

--

Hey and welcome! My name is Connor and my goal here is to put out a daily post for a full year about my game development journey.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Make ToDo List Application using React Native Expo for IOS and Android device

React Best Practices: May 2020

How to fully validate a URL in Node.JS

Positioning with Anchors in QML

The Yarn & npm Package Managers

Reacting to React

HackerRanks’ 10 Days of JavaScript

[Learning]#17 JS: loop — Part 2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Connor Fullarton

Connor Fullarton

Hey and welcome! My name is Connor and my goal here is to put out a daily post for a full year about my game development journey.

More from Medium

Quick tip — Enabling post-processing in Unity Universal Render Pipeline

Learn to code by Making 2.5 D Space Shooter Game.

Camera Shake in Unity

What are “Render Pipelines” in Unity?