- Home /
Question by
Satyendra_13 · Mar 17, 2021 at 09:44 AM ·
character controller
How can i write code if a character see another character, the another character will automatically freeze or gets trapped in cage.
@DevManuel sir, I want to make a game for our school project(Hide and Seek) and i want if a seeker see hide from specific distances, the hider will automatically freeze or gets trapped in cage.alt text
screenshot-10.png
(82.4 kB)
screenshot-15.png
(57.7 kB)
Comment
What's the problem now? Is it not working? Any errors? And what is 'MovingPlayer'?
This error means the script tries to acmes a variable called layerMask which is not given. So simply set this variable:
int layerMask = 1 << 8; // Bit shift the index of the layer (8) to get a bit mask // This would cast rays only against colliders in layer 8. // But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask. layerMask = ~layerMask;
your MovingPlayer needs a public function 'freeze()'. And when this function is called the script can freeze the hider.