Create rotation in random direction from existing rotation

by DRiFTy   Last Updated December 29, 2017 23:13 PM

I am working on a game in Unity, and I currently have a game object (object A) located at the origin. I have a child of this game object (object B), that is 10 units back on the z-axis. When I rotate object A, it causes object B to orbit at 10 units from the origin.

With that being said, I have many game objects that orbit this same way. I want (at any point in time) to be able to spawn a new game object a certain distance away from object B. This certain distance is really going to be something like 60 degrees around the sphere in any random direction from object B. So when I create a new game object, I will create a new pivot point object (object C) and a new child of that pivot point (object D) at 10 units away on the z-axis.

I know I need to create a new rotation from the current rotation of object A, but this needs to be in a a random direction and the new rotation should be 60 degrees in that direction.

Let me know if that doesn't make sense, or if you need any other information.

I am not really sure how to even go about determining these rotations, but I am currently trying to use Unity's Quaternion class which I believe will work, but I think I need to step back and see if anyone else has a better way to go about this.

Appreciate the help!



Related Questions


Random Direction Vector Relative To Current Direction

Updated December 07, 2017 00:13 AM


Set direction of rotation C#

Updated September 17, 2017 17:13 PM

Make object face another object on a sphere

Updated December 30, 2017 16:13 PM

Bullet direction incorrect around sphere

Updated December 30, 2017 18:13 PM