Reflect Angle

This forum is currently in read-only mode.
  • How can I go about doing a reflect angle? I'm not using any Behaviors, just the standard X/Y static engine.

    XSpeed: Player.X+Player('XSpeed')

    YSpeed: Player.Y+Player('YSpeed')

    I already have the angel velocity.

    Value = 1

    XSpeed: 12*Cos(Angle)

    YSpeed: -12*Sin(Angle)

    I just need to get a proper Reflect angle collision.

  • You just need the angle of the wall to reflect off of, thin sprites work well for that.

    + Player: On collision between Player and wall
    -> Player: Set angle to 2*wall.Angle - Player.Angle[/code:357lq604]
  • Well, I kind of need it to reflect of the Object current angle. It works like Pulseman's Voltecer

    Subscribe to Construct videos now

    I would need to reflect not just floors but walls. Not to mention that all the floor tiles would be at 0.

    If the object his the at floor 225, it would reflect to 135. If ita celiling at 135, it would reflect to 225.

    <img src="http://i61.photobucket.com/albums/h53/Sodisna/Sheet.png">

    Doing something like this.

  • Set angle to "2*wall.Angle - Player.Angle" does reflect the objects angle. Another way is using overlapping at offset to see if there's a wall horizontal or vertical from the object and just reversing the sign for either the x velocity or y velocity.

    Here's an example with both methods:

    http://dl.dropbox.com/u/5426011/examples3/reflect.cap made in 0.99.96

  • Worked, awesome.

    By the way, do you how to set angle based on on X/Y Velocity?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • By the way, do you how to set angle based on on X/Y Velocity?

    Basically, if the velocity is expressed both negative and positive, then the angle of the velocity at that moment of time you sample it is

    angle(0, 0, xVel, yVel)

    But you would need to take into account the current angle of the object, the velocity is applied to. When time based it could be something like that:

    object.angle = object.angle + angle(0, 0, xVel, yVel) * TimeDelta

    (If I'm not totally off beam)

    EDIT: Ah, sorry, no, the last one is not correct. It would spin the object even if the angle is already reached.

  • How would I get this "2*wall.Angle - Player.Angle" to work with X/Y Velocity?

  • [quote:2cyb294m]How would I get this "2*wall.Angle - Player.Angle" to work with X/Y Velocity?

    First convert X/Y Velocity into an angle and distance:

    angle_of_motion = angle(0, 0, X_Velocity, Y_Velocity)

    speed_of_motion = distance(0, 0, X_Velocity, Y_Velocity)

    Next Find the bounce angle:

    new_angle_of_motion = 2*wall.Angle - angle_of_motion

    And then convert back to x/y:

    X_Velocity = speed_of_motion * cos(new_angle_of_motion)

    Y_Velocity = speed_of_motion * sin(new_angle_of_motion)

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