[behavior] rex_light

0 favourites
  • Johncw87 's trace (raycast) plugin is better then this behavior. So I will recommend user try that plugin first.

    Here is the demo of reflecting using trace (raycast) plugin. (source capx)

    ----

    rex_light : adjust width until hit obstacle (not a real lighting system)

    Demo1: lights and reflection ( laser)

    Demo2 : project shadow ( left/right/up arrowkey to move the character)

  • Thank you so much, this is gonna be useful when making lasers for a game :D

  • 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?

  • 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.

  • After spending about 2 days figuring out how to make lasers and bullet-tracers, I find this excellent plugin that does it better (significantly faster according to the debug mode) and far simpler.

    However, I wonder if I might request a feature. Is it possible to exclude certain instances from the collision triggers? The player unit and his allies as well as enemies all have Shields. I was hoping the light behavior could ignore collision with all instances of the Shield object belonging to the attacker and his allies.

    The way I did it before was to save the attacker's UID and faction name in the laser/tracer's instance variables then make the laser/tracer ignore shields and allies of the same uid/faction. Basically, the laser/tracer would ignore collisions with objects from the same source.

  • Try Construct 3

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

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

    Set the collision of ignored objects to "Disable", so that they will not be tested.

  • Kyatric

    Please help me move this thread to "Completed Addons" section.

  • Moved.

  • Kyatric

    Thanks!

  • rexrainbow

    I don't think it'll work. I need the unit's shields to allow it's own laser through, but block enemy lasers so I can't disable collision. If it could ignore checks for certain instances only, instead of all objects of the same type, that would do it, I think. It's what my laser is doing now but testing shows your plugin is significantly faster (not to mention a whole lot easier to do).

  • Norbingel

    Since the checking is not automatically, you could disable the collision of target instance only, then run action, finally reset collision to enable.

    Edit: to mark the ignored instances, you might use my rex_ginstgroup plugin.

  • I will test later when I can but when I enable collision again, wouldn't it detect the collision again and set the laser length accordingly? What happens when the enemy laser is hitting the shield at the moment I disable collision? Then the laser would get through when it shouldn't.

    That looks like another handy plugin, thanks!

  • 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)

  • mattb

    I guess... you might use 4 edges (sprite) to compose a full wall. Each edge maintains a face of reflection.

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

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