Bullets and Corners

0 favourites
  • 8 posts
  • Not sure how to stop my bullets from taking really strange angles when they hit corners. They need to act exactly like rays, with infinitely small thickness but still bounce.

    Any suggestions on how to fix this?

  • I assume you have 'Bounce Off Solid' checked.

    You either a) have to use the physics behavior or b) do it with math (can't help you there sorry)

  • Hi! Thank you for the reply.

    I will probably stay away from physics for now and see if I can calculate the angles by myself. I have no other reason to implement physics in my game (as of now), so it might make things harder.

    I will also add a picture later that shows the difference in trajectories, in case it helps.

  • You might be interested in the "Raycast reflections" example from the Start page. You could salvage some of the concepts to make your bullets react as rays.

  • Here is the image of the work in progress.

    As you can see some bouncing issues are fairly noticeable. the light green lines are the actual paths the bullets are supposed to follow, and the light red lines are the lines they actually follow.

    Magistross First, thanks for the reply, and second, yes, I did use the Raycast Reflections to make this game, hence the player.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I modified the raycast example a bit to add bullet firing with ray-like bounces off solids. Plot twist, I'm not using the Bullet behavior for movement but Tween !

    drive.google.com/open

  • Bounce off solids with the bullet behavior will treat corners as rounded.

    LOS ray casting will get you the "real" angle of reflection on collision with solids.

  • Thank you Magistross so much! I was going to use a lot of variables, but this is so much easier.

    I would say it worked, but after copying the code, I restarted C3 to make it run smoother (old computer) and now the game is throwing the error 'invalid function' and won't let me open the project. I also made the mistake of no backup.

    Shouldn't take me too much time to restart my project, but this will definitely be alerted to support.

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