using UnityEngine; using System.Collections; using System.Collections.Generic; public class Inventory { public List items; public Inventory() { items = new List(); }        Create an instance (a...









using UnityEngine;


using System.Collections;


using System.Collections.Generic;


public class Inventory {


public List items;


public Inventory() {


items = new List();


}



       Create an instance (a variable) of Inventory in Robot Kyle's Movement Script. Don't forget to bring it to life in the constructor.


The next thing you'll want to do create a method to add items to the List.  The method should take in a Transform as a parameter (called t ).  To add to a list, you just call its Add( ) method and pass it the thing you want to add, which in this case would be  items.Add(t);


       Create a public method called AddToInventory( ) that takes in Transform as a parameter and adds it to the list.


       After adding t to the list, set it to be inactive by calling t.gameObject.SetActive(false); This way, the game object will no longer be seen.


Finally, go back to the Movement Script and look at OnTriggerEnter().  Now pay attention because this part can be confusing. If you look at the parameter to this method (called other), you'll notice that it is of type Collider. The collider is attached to the model that Robot Kyle collided with.  HOWEVER, remember that the model is a child of an empty. SO, we need to get the transform of the collider (the thing the collider is attached to) and get its parent. Do the following:


       Remove the Debug print statement in OnTriggerEnter( )


       Call the inventory's AddToInventory( ) method, passing other.transform.parent.



0.1) (hAbs>8.11) dfs = Mathf.Atan2 (-v, h); 45 46 47 48 tretsfo Ioluot^arelookAtvargeti:nAngleakis (efs - radsTodegs, Vector3.up)- vectorá. forvard - transfom.posit lonj transforn.LookAt oktTarget); transforn. Translate (Vector3.forward Time.deltaTime maxInput runSpeed); AErrors">



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here