Topic was automatically imported from the old Question2Answer platform.
Asked By
Marirari89
Hello everyone! I am unsure where I would post a question like this, so I posted it in the Godot forums as well.
I am trying to make a Doom/Wolfenstein clone with billboarding 3D so the enemy sprite is always facing the player. I know how to do the billboarding effect, but I also want to change the enemy sprite based on whether or not the enemy is facing the player. I want to see the enemy’s back if the player is behind the enemy, the front left if viewing the enemy from a front left angle, and right side of enemy if viewing from that angle. Hence, I would need to change the enemy’s sprites accordingly.
Does anyone here know how one would go about programming such a feature?
To determine which sprite should be drawn, using the dot product between the player’s position and the enemy’s position will be what you need. You then need to use a series of if statements to assign a sprite depending on the value of the dot product.