0 Favourites

# How do I set angle compared to another random angle

• 4 posts
• So, I have objects spawning at random points, moving towards the player, with a random angle +/- a certain degrees, so their angle is never known. When that object is killed, it spawns 2 new objects. I want those 2 new objects to then move out a random +/- degrees in relation to the angle the object they spawned from was moving.

Ex. Object 1 is moving at a 65 degree angle. I want the 2 new objects to start out moving at that 65 degree angle, but then have their own variance of +/-70 degrees

If Object 1 is moving at 20 degrees, then I want +/-70 off of that 20 degree angle.

Currently, the objects that spawn are set to angle (X,y) where x,y is the player

Then rotate clockwise random (-25,25) to give some variance in where they go

So, where do I go from there, to make the new spawned objects move in the direction I want them to (the direction the original object was going)

• I think you should create the two new obect, before you destroy the old one. In this way you can set up their angle depending on the old object.

Something like:

-objetctA is killed

• > create objectB

-> set objectB.angle = objectA.angle + random

• > create objectC

-> set objectC.angle = objectA.angle + random

-> Destroy objectA

• Worked well Borgi thank you. Had to disable collision for object.a first so the 2 new objects wouldn't collide with it. I appreciate your help and knowledge!