How do I figure out a random physics angle

0 favourites
  • 7 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • Ok, so my original spawning object is coded like this.

    ObjectA Apply Physics Impulse 5 towards random(x,y), random (a,b)

    It's the best way I know how to select a point on the map as the area I wanted the object to go, but have a variance so it doesn't always go to that object.

    Now, when ObjectA dies, it spawns 2 ObjectB's. I want ObjectB to move at the same angle ObjectA was moving, and then add in a variance on it.

    I did this exact thing with Bullet behavior, but of course I had physics problems, so now I am trying to do it with Physics behavior, and well, it's kicking my Butt trying to figure it out. None of the objecta.physics. commands looks like they will tell me the angle of motion. I cant use ObjectA.angle from what I have seen.

  • when object die make add action and say : system create an ObjectBsame position with ObjectA for examble...

  • That's just creating it though isn't it? It's not creating the movement or setting the angle

  • Well you can get velocityX and velocityY from the physics object, which would give you the moving-angle if needed..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tried messing with that some, but I guess I'm not trying the right event action combo. Currently I'm trying to apply an impulse at an angle, and I guess im not sure what I would use within the angle field that would give me the actual angle the first object is moving at. Velocity x and Velocity y I guess just tells you the rate at which an object is moving at the y axis then the x axis... but I dont know how I would formulate that into an angle.

  • I guess you could get the angle with this expression:

    angle(object.x,object.y,object.x+object.physics.velocityX,object.y+object.physics.velocityY)

    But I must admit I'm a bit tired.. haha..

  • Very good stain, that did the trick, now I just gotta play with it to find out the best way to randomize it, and make 2 objects spawn without spawning on top of each other and going flying into random directions

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