0

I do a RayCast to the terrain and then use the RaycastHit.normal to plant flags.

enter image description here

I would like to have the flags to point up with the normal, but have them all face the same direction. As seen in the image flag 1 points to left of the screen and flag 5 to the right. I understand why, but do not know how to rotate it.

I saw LookRotation (Unity) has an override that takes a forward direction too. I thought it would work with say Vector3.Forward, but if a flag is placed on a wall it points into the wall.

The direction or angle they face can be set by the player.

I have a hard time understanding quaternions, every time I think I do, I get stuck.

Any tips ?

DMGregory
  • 134,153
  • 22
  • 242
  • 357
  • "but if a flag is placed on a wall" They can be oriented toward the same direction only if this direction is not the same as the surface normal, so if the wall's normal is pointing toward x+, and the user wants them oriented toward x+, you have an issue. What does your game design say when this happens? – Vaillancourt Apr 20 '21 at 14:15
  • I answer a variation of this question every few months. Check the TurretLookRotation method in this answer for a way to control the up axis exactly, while guiding the forward direction as close as you can get it given that constraint. – DMGregory Apr 20 '21 at 15:16

0 Answers0