Unity Artificial Intelligence Programming , Fourth Edition by Davide Aversa
Author:Davide Aversa
Language: eng
Format: epub
Tags: COM012040 - COMPUTERS / Programming / Games, COM060080 - COMPUTERS / Web / General, COM051310 - COMPUTERS / Programming Languages / C#
Publisher: Packt
Published: 2019-04-24T07:49:32+00:00
This is the initialization method for our boid:
void Start () { randomFreq = 1.0f / randomFreq; //Assign the parent as origin origin = transform.parent; //Flock transform transformComponent = transform; //Temporary components Component[] tempFlocks= null; //Get all the unity flock components from the parent //transform in the group if (transform.parent) { tempFlocks = transform.parent.GetComponentsInChildren <UnityFlock>(); } //Assign and store all the flock objects in this group objects = new Transform[tempFlocks.Length]; otherFlocks = new UnityFlock[tempFlocks.Length]; for (int i = 0;i<tempFlocks.Length;i++) { objects[i] = tempFlocks[i].transform; otherFlocks[i] = (UnityFlock)tempFlocks[i]; } //Null Parent as the flock leader will be //UnityFlockController object transform.parent = null; //Calculate random push depends on the random frequency //provided StartCoroutine(UpdateRandom()); }
We set the parent of the object of our boid as origin, meaning that this will be the controller object for the other boids to follow. Then, we grab all the other boids in the group and store them in our own variables for later reference.
The StartCoroutine method starts the UpdateRandom() method as a coroutine:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Blood, Sweat, and Pixels by Jason Schreier(3485)
Dawn of the New Everything by Jaron Lanier(2690)
Godot 4 Game Development Cookbook by Jeff Johnson(2555)
The Art of Doom by Bethesda(2037)
Significant Zero by Walt Williams(1885)
Creative Character Design by Bryan Tillman(1842)
World of Warcraft Chronicle Volume 3 by Blizzard Entertainment(1663)
The Ultimate Roblox Book by David Jagneaux(1617)
Art Of Atari by Tim Lapetino(1567)
Pillars of Eternity Guidebook by Obsidian Entertainment(1539)
Dawn of the New Everything: Encounters with Reality and Virtual Reality by Jaron Lanier(1539)
1628927445Game by Unknown(1478)
Unreal Engine 4 Virtual Reality Projects by Kevin Mack(1475)
Mission Python by Sean McManus(1457)
Unreal Engine Virtual Reality Quick Start Guide by Jessica Plowman(1453)
The Ultimate Player's Guide to Minecraft by Stephen O'Brien(1421)
Learning D by 2015(1419)
Unity 2018 By Example by Alan Thorn(1394)
Road Games by Road Games(1369)
