- Home /
Other
How to make a 2D Character react to In-game A.I (Objects)?
I am making a 2d Game and i want to add more realism in the game.
i want my 2d character to be in neutral position and when the enemy comes to a specific distance to him i want the character to be in the agitated stance.
I want him to react when he gets hit too.
Can Someone Aid me in creating the Scripts?, maybe some code?.
Asking for scripts is frowned upon. Frankly, this question is too open-ended. There are any number of ways to achieve what you're asking for, and which approach is appropriate depends entirely upon your scene and the nature of the game.
Just to get you started, how about investigating Triggers in the documentation. They'll help you detect objects - so for instance, your enemy object could have a trigger which reacts to the player by changing the enemy's animation / stance.
To react to getting hit - this is even more subjective, since you don't mention how the enemy detects that he's been hit. Whatever method detects a hit could trigger a specific GotHit animation on the enemy, or push him away, or whatever you want.
You'd really benefit from spending some time in the Learn area of the website. A lot of common requests like this are addressed in great detail there.
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Limiting Player Movement in 2D game? 0 Answers
top down 3d camera rotation question 2 Answers
How to make basic AI in a 2d game? 4 Answers
touch position to world position 2D 2 Answers