Ahoy! Welcome aboard the development train!
As you all know flowlab is not a 3D engine, but we are able to create Wolfenstein 3D. I’m trying to create a simple engine that everyone is able to use. I could just use a ton a switches and Ray Casts to set custom FOVs but I had the idea of using a repeater so I’m sticking with it ,unless it fails. And it does work kinda, but it’s making the engine drop to 7 fps. I already set up 360 Ray Casts with my custom shadows thing I’m working on (it works at ~28 fps) and I don’t feel like setting up that many rays so If anyone finds a good way to optimize this that would be great.
(A draw function would be great for this Grazer, I believe tinkersmith suggested this before )
So here’s an explanation to how it works and what’s causing the fps to tank (Spoiler, it’s messages/expressions)
This is how it works, first I evenly space out the the objects that will display the wolfenstein effect, pretty simple, not more more than that.
Ok now on to the important part. First set the FOV, this will determine how many times the repeat will go off (The repeater activates a Ray Cast that many times each frame). As the repeater outputs it is increasing a Number behavior by 1, this will determine which section of the screen the ray cast will account for. Another thing the repeater does is increase another value, this determines the angle of the ray, from there it will cast the ray. 2 messages will be sent to the Display objects, Length and Which.
Length gives the height that the Display object will be, and Which tells which one needs to have its height increased.
What what’s causing the FPS drop is ~13ms of Mailboxes and ~12ms of Expressions. I have the FOV at 90, so that means each frame 180 mailboxes go off (2 in each display object) + 90 expressions (1 in each display object)
@JR01 if you had any ideas besides me setting up 90 seperate rays rays that would be nice
@Yoann I know you have your engine, but I think I remember you saying something about not using ray casts.
@ Anyone else with ideas
Btw sorry if the code is a little messy, I made this this morning and haven’t cleaned it up
cool, i’m gonna take some time to figure out how to use this and then make a game with it
I’m going to probably change it quite a bit to reduce the lag, but once it’s done an in-depth explanation will be added to the bundle
Also another strange thing is that the ray cast is outputting the wrong number(?). If I’m right next to a wall it should output something a value around 32, but instead it’s outputting ~200 and idk why. I’ll check to make sure the angle of the rays are correct later
You need to put a position block in the walls, so their collision won’t merge together.
Also, Yoann’s game did use Raycast, it took me a while to find it though.
Also, I’ve made many examples myself trying to produce these effects. Here’s my opinion on the matter.
The problem with Raycast is that to get a good measurement, you have to “grow” a scan to get the correct distance. But this isn’t efficient because they already do this and re-scanning many times in a single frames does slow the game down depending on the loops in the system. I also took a couple attempts at using Rotation as a scale, but have come up with more problems there.
I think the best solution will come from a List structure to create a map, and mixed with internal calculations from expressions to get the exact values you’re looking for to create this effect without many problems or lag.
kk, I’ll look into using lists and see what I can get from there, thank you.
Best of luck, I haven’t looked much into or had the time, but I’m tracking down and finding the calculations to do it this way with expressions. Raycast is still an alternative, it’s just it will always be blocky because of how they work. I also find it to help to use the Point to Line method to remove fish eye effects.
Flowlab Game Creator - Point To Line
Also, I guess I can share my last test since it was below my expectations…
Flowlab Game Creator - 3D v7 - Raycast 45
Quick question, why does the object that contains the Ray Casts need to have collisions turned on?
Nvm, must have been a weird glitch
So before I work on using lists to create the walls I wanted to try something else with ray casts.
I have every wall spawn a 1-pixel object all around the perimeter of it. that way the distance of the ray is always accurate. The FOV is also only 20, so at that view there is almost no fisheye effect.
I spaced the spawning of the perimeter between 1-30 seconds to help it load.
So it kinda looks like the version on the right, but if it was optimized it would look like the image on the left
Wow it got really complex
I tried looking into making a full 3D effect using wireframes but I got wayyy in over my head and I didn’t really have to work on it. I think being able to draw specific pixels on the screen (without having a million objects lagging) would make it a lot easier.
yea, i think draw functions would be real nice
If grazer did implement a Draw behavior and Rays outputted the accurate distance traveled Wolfenstein could easily be done without being taxing on the engine (Assuming that the Draw behavior takes a lot to calculate)
Before I work on trying to see if I can use Lists I wanted to see if I could solve the biggest problems with raycasts.
I decided to try and use physical objects because I would be able to get accurate X and Y values to use as my distances, and it works decently, but there are some problems.
- Emit stops working after something like 200 objects have been spawned by it, so it’s impossible to have a constant field emitting from the player. (Maybe a bug)
- The speed of the particle’s travel is very particular. If it’s too fast it will output a distance that is completely wrong or it won’t even hit the object.
- If the object moved slower there would be a big delay in the player’s movement and what is actually shown (But it is very accurate)
- Having it at high speeds also seems to cause a reversed fisheye effect.
- Collisions are really high on this, so unless collision performance was improved it runs anywhere from 10-30 fps
Anyways, I’ll be working on some Wolfenstein things off and on, but for rn, I’m mostly focusing on getting a game finished.