- Home /
Add small offset to Y rotation?
I have created a projectile that gets destroyed after traveling a distance. When it gets destroyed, I want to spawn 5 new projectiles that each have a small offset on their Y rotation. I created this method:
void split()
{
Quaternion newRotation = transform.rotation;
newRotation.y -= 0.3f;
for (int i = 1; i <= 5; i++)
{
spawnSplit(newRotation, transform.position);
newRotation.y += 0.15f;
}
StartCoroutine(DestroyProjectile(0f));
}
This works kind of right. However, this doesn't work like I want. When the original projectiles' Y rotation is around 0, all the spawned projectiles will only have a small offset, but when the original projectiles' Y rotation is around 1, the spawned projectiles will have a big offset.
How can I make sure all spawned projectiles will have consistent offsets? Thanks for reading :)
Answer by 334499p · Nov 26, 2015 at 04:08 PM
You can use euler angles to accurately predict how the projectile will rotate based on 360 degrees
newRotation *= Quaternion.Euler(new Vector3(0, 15,0));
Your answer
![](https://koobas.hobune.stream/wayback/20220612050447im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Weird offset while Instantiating GameObject 1 Answer
Spawn Rotation not Working? 1 Answer
need help with roation 2 Answers
Spawn bullet in front of object then apply force? 1 Answer
How to make my new Instances spawn in the right direction? 1 Answer