There are 2 gameobjects:
- Character (C)
- Opponent (O)
in a 2D fighting game.
How does Opponent detect the distance of Character?
(O) ----------------- x -----------------(C)
How to get the x value dynamically?
(O) and (C) are keep moving.
There are 2 gameobjects:
in a 2D fighting game.
How does Opponent detect the distance of Character?
(O) ----------------- x -----------------(C)
How to get the x value dynamically?
(O) and (C) are keep moving.
You can use Vector3.Distance:
var distance = Vector3.Distance(character.position, opponent.position);