- Home /
Question by
GamesbyJP · Jan 09, 2019 at 01:42 PM ·
scripting problemmessagedesign-patterns
Calling OnControllerColliderHit() from script not attached to characterController
Hello everyone,
I'm working on a game, and my code design looks like this:
The arrows mean that the object on the left knows the object on the right, but not the other way around. This to prevent spaghetti code in the long run.
The characterBehaviour tells the statemachine when to switch state, and knows what the current state is.
Now, my problem: I'm trying to call a message from state1, which occurs in the characterBehaviour script.
So for example: in the characterBehaviour script, I can call the function OnControllerColliderHit(), and it gets triggered as it's supposed to. But how do I call this message in State1, keeping in mind that State1 doesn't know that characterBehaviour even exists?
Thanks in advance!
unityanswers.png
(24.0 kB)
unityanswers.png
(24.7 kB)
Comment