Quantcast
Viewing all articles
Browse latest Browse all 133

I can't get my Quaternion rotation to work

The first line of my code below makes my object follow the rotation of the object it collides with. The part after that is supposed to make the object rotate 180 degrees (go in opposite direction of collision object), but doesn't do anything at all. I've tried a few different approaches, but none of them seem to do anything. Any help is much appreciated! // follow the rotation of the object it collides with: gameObject.transform.rotation = other.transform.rotation;
// rotate 180 degrees (go in opposite direction of collision object): var lookPos = other.transform.position - transform.position; lookPos.y = 0; var rotation = Quaternion.LookRotation(lookPos); rotation *= Quaternion.Euler(0, 90, 0); // this adds a 90 degrees Y rotation
// apply interpolation over time: transform.rotation = Quaternion.Slerp( transform.rotation , rotation , Time.deltaTime*smooth );

Viewing all articles
Browse latest Browse all 133

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>