Adding Cats
- zm02stor
- Sep 4, 2022
- 2 min read
[28 Aug]
I started by making a basic cat prefab - a cube with two box colliders and a rigidbody. One of the colliders is a trigger which will enable the player to pick them up. Created 3 basic materials for the fur: black, orange and white. The spawner is an empty game object with the script attached.
After the random position is decided, a material is assigned to the basiccatprefab. For testing purposes, a cat is spawned when Q is pressed.
Pickup script:
An empty gameobject is attached to the player and placed into position where the cat will be when picked up. If the player enters the trigger of the cat, and they press a key the cat will be parented to the player. A check is run when the player presses another key to drop the cat, if they are then they are no longer a child of the player and their rigidbody's iskinematic is set to true again. IsKinematic can be used to disable if the object can interact with other physics objects.
Basic Wander:
As of now a basic wander is used on the cat, it uses a naive approach where a random destination is decided at each frame per second which gives some jittery movement. It will later be improved to have smooth movement by projecting a circle and chosing a point to follow at the projected circle. [fix]
3 functions are used for the cat to have randomised movement: Move(), RotateLeft() and RotateRight(). The cat moves forward in the direction it is currently facing using Move(). A random value is used to determine if the cat will rotate right or left, if it is >25 the cat will rotate right and if <25 the cat will rotate left.
Goals for next time:
add enemy navmesh agent
fix pickup (you can pickup more than one cat)
basic minimap


Comments