mattb's Forum Posts

  • Ruskul - these are the conditions available & there's an 'on pre step' trigger.

  • Hi ruskul, I only skimmed your post but have you looked at the Chipmunk physics behavior? From Rojo's post:

    [quote:1sof8dpk]* Collision info with the "Post Collision" condition. With it you can get:

    1. Kinetic energy of collision.

    2. Impact of a collision.

    3. UID of other chipmunk object hit

    4. Number of contact points and the point, normal and penetration depth of each.

  • Is there a way to set linear or angular damping per object? I find those to be essential features of the in-built physics behavior for tweaking movement & doing things like underwater effects. Prevent rotation is another handy feature that's missing, but I suppose it'd be easy enough to set these with events.

  • Thanks, this sounds great. The post collision trigger stuff should add some interesting new possibilities over the current physics engine. Chipmunk's lack of tilemap support is a problem for me though, but I'm sure Rojohound will get that working in the future.

  • I posted this under bugs & Ashley confirmed that it's a limitation of the box2d engine. The same thing happens to a lesser extent with asm.js, so I'm still looking for a workaround. Any ideas?

  • Problem Description

    If you toggle a physics sprite between movable & immovable while it's sitting on top of an immovable sprite, it falls through the one below when toggling back to movable.

    Attach a Capx

    Attached below

    Description of Capx

    As above

    Steps to Reproduce Bug

    Click on the red sprite to toggle moveability.

    Observed Result

    Clicking once makes it fall into the floor slightly then move back up. Clicking repeatedly can make it fall through.

    Expected Result

    I'd like it to not move, but this may just be a limitation of the physics engine.

    Affected Browsers

    • Chrome: yes
    • FireFox: yes
    • Internet Explorer: don't know

    Operating System and Service Pack

    ____ Win7 64bit ____

    Construct 2 Version ID

    190 (64bit)

  • I've got a situation where I want to switch an object's physics between movable & immovable, however there's a problem with this as you can see in the capx. Click on the red sprite to toggle, & the sprite falls through the floor when it becomes movable (this gets worse with each click).

    I've tried moving the sprite up 1 pixel before it's set to movable again to avoid overlaps, but that doesn't work. It seems to have no collision with the floor for a few frames. Any ideas for a workaround?

  • I didn't check lunatrap's capx (don't have the latest c2 installed), but if it's not using rex's light behaviour then I'd recommend you use that instead of an event-based solution - it's much easier & seems more efficient with lots of laser bounces:

    Just apply the Light behaviour to your laser sprite (a thin sprite with the origin at the left side), & with one action it will extend towards a custom obstacle or a sprite with the solid behaviour. You can do this every tick or manually.

    After the laser has hit, you then get the hit object's UID, hitX, hitY & a reflection angle (eg. to pick the hit object you would do: Spritename | Pick instance with UID Laser.Light.HitUID)

  • rexrainbow - please do Here's a version with better textures & opacity falloff...

  • Got the events working at last. Capx is attached below...

  • Well that was embarrasingly simple now you've explained it Thanks! Also thanks for showing the '?' operator, hadn't seen that before.

  • What I'm trying to do is work out which side of an arbitrarily rotated rectangular sprite is hit, so I can then get a reflection angle for the Light behavior plugin.

    I can already do this for sprites which stay at 0 degrees, as you can see here:

    https://dl.dropboxusercontent.com/u/52354372/detect%20rectangular%20sprite%20side.capx

    That's basic trig comparing the angle between sprite & hit point with 4 ranges for each side.

    The problem I'm having is working out the math for a rotated sprite. Any idea how to do this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • mattb

    The parameter of expression:ReflectionAngle is the normal vector. I only use the angle of the wall to be this input, so that it might be strange at the edge of wall, like your image 2 shown.

    So if I wanted to get correct reflections on all sides of a rectangular sprite, the way to do this would be:

    1. determine which side of the sprite is hit (by comparing the angle between sprite & hit point)

    2. for the 2 sides of the sprite with incorrect reflection, set the reflected angle of a Laser sprite to 'Laser.Light.ReflectionAngle(Sprite.Angle+90)'

    Is this right?

    (I've tried to set this up & I think my code for step 1 is faulty, but just wanted to confirm that I'm on the right track)

  • Another thank you for sharing this & all your other c2 addons.

    I just wanted to confirm something about this behavior- does ReflectionAngle only work for the sides of a sprite that are parallel to the sprite's angle?

  • That was it, thank you The text was just for debugging, & I thought destroying then creating it every 0.1s for <100 objects wouldn't make a dent in performance. I'll be more efficient with my debug text in future.

    So it's good to know that the pathfinding optimization works perfectly. I'll post an example file once I get a more complete system & hopefully help someone else out.