Hey guys.
I am trying to spawn a "tower" in front of my controller, similar to Orcs Must Die, and place the tower on the floor or terrain. My problem is, whenever the floor is angled, my tower does not align with the floor.
-I have tried casting a ray, getting the hit position, normal.
-Set the position of the tower to the hit position.
-I round the vector so the tower snaps to a 1x1 grid system
-I use the "get quaternion from rotation" custom action. From Direction = HitPosition, to direction = HitNormal
- rotate the tower to that quaternion
but I get mixed results, where my tower kinda gimbals around my player. I have also tried casting a ray straight down from my tower, still doesnt rotate the way I want it to.
I found a code to align objects from the unity website...so in theory...this should work?
//with this you rotate object to adjust with terrain
transform.rotation = Quaternion.FromToRotation(Vector3.up, rcHit.normal);
Anyways I am stumped...I am sure somebody on the forums here have tried aligning objects with the floor at some point making their game? any help is appreciated! Thanks.