Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 2 of 2 |
|
|||||
|
@just_in_case, I absolutely agree. In school they don't tell you that this sinus, cosinus tangents stuff will be vital one day in order to fight the encircling zombie hordes ^^ . Esp. in 2D games coding, the day one grasps this is like a geometric catharsis. |
||||
|
While we're on the subject, I'd like to give some further advice, that may be useful for others too, in the future. Pointing the NPC at you immediately may look quite unnatural in a game. Therefor it may be a good idea to use what I call a delayed rubberband relation. You would not point the NPC directly at the camera, but use an intermediary position, that follows the camera slightly delayed, but follows the faster, the quicker the camera moves. For the sake of simplicity one may not do this with the angle, because wrapping the 360 degrees may be troublesome, but instead just delay the position in question. So you check the camera position, as well as this delayed objects position (eg a folder node). You calculate the distances on XYZ, then you add something like 10% of the distance on each axis to the delayed objects position, so it takes a step towards the camera. If the player stands still, that object will catch up smoothly. Initially the object is positioned at the cameras location. Then frequently do something like:
And then you would do the atan2 thing with this object, instead of the camera. |
[ 1 2 ] Page 2 of 2 |
|