How do I set angle compared to another random angle

0 favourites
  • 4 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template for top-down view games)
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Borgi, was hoping you could provide more help. Before I was using the bullet behavior, and setting the angle for that wasnt too hard. Now I am using Physics behaviors, and moving objects with impulses. Now, should I be using the apply impulse at angle action, and if so, how exactly do I get that to do what I was trying to do originally.

    Currently I have.. Physics impulse 5 at angle objecta.angle +random(-20,20) but my object isnt even moving with that, and not sure why because it seems like it should work.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)