Unity

From bibbleWiki
Revision as of 04:42, 29 August 2021 by Iwiseman (talk | contribs) (Created page with "=Introduction= ==Mouse Manager== Demonstrated who to do a mouse manager which determines what the cursor should look like when interaction with an object occurs. To do this th...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

Mouse Manager

Demonstrated who to do a mouse manager which determines what the cursor should look like when interaction with an object occurs. To do this they

  • Create game object called Mouse Manager
  • Set up a script which exposes 5 different Texture2d textures extending monobehaviour
  • Implement update which is fired for each frame
  • Import assets for cursors, set the texture type to cursor
  • Attach Script to Mouse Manager object
  • Drag drop assets to Mouse Manager slots from script
  • Make an new layer and name it clickable
  • Go to mouse manager and say clickable is possible on clickable layer

Movement

This was quite complex (maybe first time around)

  • Import the NavMeshComponents
  • Add NavMesh Surface empty game object
  • Set the agent type on NavMesh Surface Object
  • Pressing bake shows what cannot move
  • We need to exclude the player from this
  • To exclude the player we need to
    • On the mesh exclude the player layer
    • On the Player object assign the player layer to the player object
  • Next create a player controller class in a script which has an agent and within start() we get this agent with GetComponent<NavMeshAgent>()
  • Back in the mouseManager script create a delegate for EventVector3 OnClickEnvironment
  • In the clickable if statement call the function assigned to the delegate from the GUI
if(input.GetMouseButtonDown(0)) {
   OnClickEnvironment.Invoke
}