I want to make raycasting on construct 2

Not favoritedFavorited Favorited 0 favourites
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Order of events matter. You'll want to set up the rays first, then do the raycasting, and then do the wall overlap highlighting. Plus you are using just one ray so there isn't much to see.

    If you want some examples to mess with and get ideas from here are two.

    First one uses a binary search to find the ray hit points. Then it loops over the wall tilemap and places light squares on every tile that overlaps a ray. If you get gaps between lit walls then you probably need to increase the number of rays.

    dropbox.com/scl/fi/30gmdo3qc71oqmltzmzrs/ray_cast.capx

    Second one is similar to the stepping idea I first described but it's tuned to step a grid at a time. Resulted in a nice fov view too, and walls are lit as a side effect of that. Again, there can be gaps if the ray count is too low.

    dropbox.com/scl/fi/jcyk0b8qjzgrokxu0ti1y/ray_cast_tilestep2.capx

    Either are decently fast. When you have loops in the event sheet you can make them a lot faster by avoiding picking inside then when you have a high iteration count.

    Anyways, they provide some ideas to mess with. There are a lot of possible improvements with both but the satisfied my tinkering for the moment.

  • any other simple ways just to create a laser like the way a ray is fast with loops? like in a very simple way no ids or indexeses and stuff like that

  • Sure. Just make a thin sprite angled in the direction you want it to go. Then starting with it short make it longer till it collides with something. That’s basically it.

    All the rest is doing things to make it faster and more accurate.

  • the thing is i dont know how to make it faster. i want to make for example a shooting mechinsm but instead of projectile bullets make it like laser detector i dont know? like how the bullets work in team fortress 2

  • If you aren’t concerned with where the ray is hit you could set the ray angle, then set the size to 1000,1, then do events like

    Ray: overlaps wall

    Wall: pick closest to Ray.x, Ray.y

    Beyond that I don’t know what to tell you. Try searching for an addon that does raycasting for you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dear rojo hound thank you. who are you? I have seen you everywhere

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