EARTH DEFENDER QUEST: ‘Rotate the Towers’ - Solutions

Quest: Earth Defender Quest
Challenge: Rotate the Towers

Feel free to share your solutions, ideas and creations below. If you get stuck, you can find some ideas here for completing this challenge.

I went with this to rotate the towers

var newDirection = Vector3.RotateTowards(mylaser.transform.forward, target.transform.position - mylaser.transform.position, Time.deltaTime * missileSpeed,0f);

mylaser.transform.rotation = Quaternion.LookRotation(newDirection);

This one took a bit of thinking. I’m not sure that my solution is the cleverest or the best one, but basically all I did was reorient the individual pieces of the tower prefab, so they were aligned with the z axis (what unity uses as the “forward vector”). Then, I just simply set my instantiated tower to rotate and look at the planet. Now, all my towers correctly rotate away from the planet when they are placed.


Privacy & Terms