I have a suggestion for Halloween, it’s basically stormworks with volcanic eruption theme. The sky is dark because of the volcanic ashes, will result low visibility. You won’t be able to fly aviation crafts in certain height because of ashes, there will be more lightning,waves,tsunami and megalodons because of volcanic eruptions. The trees will catch fire more often, rocks will hail from the sky, high temperature might lead to death at beginning, but gradually it will become colder and result hypothermia. You will need to save multiple people: Billy n bob: brothers with muscles and brains who runs jank airline MrNjJersey: chief engineer of islands Lord Oscar von spammals: rich man who loves to collect steam ship with bridddge wings Frantic n endoskull: local coastguard somehow has tanks missile and bombers. Spycake: pirate with a legend of catching a megalodon
Good tutorial but your math is WAAAAY incorrect. Not sure what you got going on there but you're desired range setting will not display targets at the appropriate locations in relation to the source. The correct adjustment for displaying on a 64x64 screen is (32 / desired range) * target distance. Then you plug this new distance value into the w/2 + distance * math.cos(r) equation and same for the sin equation.
@@lordraven1991 Its 99% there and you dont need to change any of the code just some logic. Basically what hes saying is set the value of the Constant (5000 in the vid) to 32. Connect that to the x input of your first f(x,y,z) block (starting from the top left going right). Now you want to divide that number by the range you set on your keypad, so the keypad's output will be your y input on the first f(x,y,z) block. The equation of that block should be x/y. Now, youre going to need to multiply the resulting value with the output coming from your radar for target distance, so the x input for your second f(x,y,z) block will be the output from the first function block (what we did above) with the target distance coming from your radar being the y input. The equation for the second function block should be x*y. Connect the resulting output of the second function block to the second memory register (the function block that Jersey has it connected to in the video (x/32) can be deleted). If you set everything up exactly as Jersey does in the video with these changes everything should work without changing any of the LUA code.
@@AClownShoe I will have to upgrade my diagram with this, thank you. I had a friend take a look at it after a while and the best he could do was to get the blips to appear but the line wouldn't move.
o yea...i have been waiting for this, trying to get this working for a while xd small tip, the on/off composite and the number composite are separated, so u can have number channel 1 and on/off channel 1 at the same time ;)
If anyone comes across this like I have much later on, I wanted to share a bit of a better method for figuring out distance. Instead of having that zoom thing, you can have the entire 5k range displayed on the radar, but not linearly so you still have nice resolution close to you, but still see stuff 5k away. The key line of code is: distance = (math.log((math.exp(1)-1)*(distance/5000)+1))^(1/1.3) -- with the 1.3 being the value to control the scaling factor so you get more resolution closer or further away. Here is my full code. I'm not using the velocity pivot either. Just plugging in the yaw from the sensor. function onTick() degree = ((input.getNumber(1)+0.5)*360)*math.pi/180 distance = input.getNumber(3) test = input.getNumber(1) isTarget = input.getBool(2) targetLoc = ((input.getNumber(4)+0.5)*360)*math.pi/180 end function onDraw() w = screen.getWidth() h = screen.getHeight() r=(w+h)/4 sweepX = math.cos(degree+(math.pi/2))*w/2+w/2 sweepY = math.sin(degree+(math.pi/2))*h/2+h/2 if distance < 0.2 then isTarget = false end distance = (math.log((math.exp(1)-1)*(distance/5000)+1))^(1/1.3) targetX = math.cos(targetLoc+(math.pi/2))*distance*w/2+w/2 targetY = math.sin(targetLoc+(math.pi/2))*distance*h/2+h/2 screen.setColor(0, 255, 0,200) screen.drawCircle(w / 2, h / 2, r) --screen.drawText(30,30,distance) screen.setColor(0, 255, 0,100) screen.drawLine(w/2,h/2,sweepX,sweepY) if isTarget then screen.setColor(255,0,0) screen.drawCircleF(targetX,targetY,1) end end
You can't detect multiple targets in one line, but it will detect multiple targets if one is not blocking the other. The radar can't see through objects, so it will only detect the closest object and not the ones behind it if they are in one line.
you can also use the yaw of the radar to instantly move, it is much faster. I count by 0.01 every tick, and the output to yaw is the variable -0.5, and when the variable gets to 1, it's set to 0
@@MrNJersey Oh, hi there, wasn't expecting a response, I haven't used radar like ever until now. I'm currently making a emergency beacon locator which involves radar. I was having trouble with it so I looked at this video just to see how you made it work, turns out I was doing it right, just messed up a few numbers.
What annoys me as an ex-navy officer is that radars like that do not actually turn. The turning component itself is inside the outer protective shell which is static. They should fix that so that the thing has an inner pivot and you set the turning speed but you do not actually see it turning. That annoys me to no end. 😅
how did you figure that the radius of your circle is only 32? i really wish ya said how ya got that so it works for more then 2x2 -_- but thanks for puting this up
Is someone able to explain why the sin and cos are where they are and what they are for? I would like to make stuffs like this though my trig is waaaaaay below where it needs to be :/
Is everything in this tutorial still accurate or have any subsequent updates altered anything? I've just been through it step by step (with painstaking care!) and it was all working until I did the step adding the pulse and NOT block, and now the returns are just appearing in the centre regardless of what I enter in the small keypad. Before that step the distance I entered into the keypad was making a difference to where the returns were displayed on the screen... Now my brain hurts...
I followed everything you showed on video and still can't get my radar to show a line so I'm gonna up load my yellow and grey tanker to see if you can fix it please my steam account name is jrock 781
This tutorial doesent work in 1.0 for some reason the dot does not display on the radar most of the time. However it works fine with the player. It will only display players and half the time the dot is in the incorrect position.
Same, sort of. I follow the tut, get a quick red blip on the screen, then nothing. I reset the x4 & y4 back to "a" from "ta" and then I get the solid dot in the middle. Can't figure out where I'm going wrong
@@TheFuriared I've got the capacitor at 2 sec discharge and the memory registers at 5 secs. He says something about resetting after five secs in the video. I've tried them at 0 too, no joy
One thing to shorten the video use a paste bin or something like that so people could do it faster. You aren't teaching them anything so making the video shorter by making a paste bin would be helpful.
Not a great tutorial. 1. Don't use 6.28 for the love of god, it's not precise enough and you WILL get desync pretty quickly. Did you even test this? Use 2pi instead. 2. Your range function is nonsense. It's blatantly obvious just from the video that it's nowhere near accurate. You need to use the radius of your circle in your function. The maximum range should just be for clamping purposes.
@@alanowa123 it wil i tink. Ye per rotation it doesn't matter but the amount that he is of on 2pi is gonna stack up after a wile and the radar will be of
@@bomoonen7453 game engine itself is only accurate so much. It can't calculate pi every time it has to do something, so im sure even in code its 3.14.... and not pi.
I build this radar from the tutorial. A few tips. DONT use 6.28 and use 2*math.PI. You will notice once you use it in a mission after about 20 minutes the radar and the screen don't correspond. Pretty much useless radar.
Nice tutorial. One warning though. 2*pi is 6.283185 etc.... and not 6.28. That means your input to the Lua script has an error of 0.00319=0.18 degrees. Though that error is multiplied for each revolution, so after an hour of running it will be almost 90 degrees behind. Fortunately the fix should be easy: do the fmod to get rotiation in the range of 0-1 before you multiply to prevent accumulating the error.
@@ChrisVTitus Pi is an irrational number so even the one provided by game or lua will be just an approximation, albeit really good approximation for the purpose. Still the mentioned method of using fmod together with using 2*pi instead of 6.28 would virtually remove the error and prevent any accumulation.
@@Rodzynus I used a counter and some blocks and equations to be able to make it rotate using the facing input for the radar instead of a robotic pivot. It is basically the opposite of an equation I used to change the input from the compass sensor into a magnetic bearing.
Hey man, What you've built is fantastic and I can see the functionality of it. However, I myself engineer and maintain RADAR systems on a daily basis, looking at feeds and analysing input and output data from loads of variants of radar systems. One thing they all have in common is what's called a CFAR (Constant False Alarm Rate) this essentially identifies moving targets and eliminates those that are stationary after building up what's called a Clutter Map (Maps everything that RF bounces off of and is collected by the receiver, building a map of stationary object that were there the last 4-5 rotations). If you could, would it be possible to show targets that move? Like yourself, and not just the tank in the background?
Your math is wrong. For one, before going into the math, you should use the "pi" built-in in Lua's math library to convert your angle to radians. Additionally, as far as math is concerned, you should be adding the center(x) or center(y) of the circle to r*cos(a) or r*sin(a), where r is the radius, and a is the angle. Your functions for x2 and y2, when drawing the line, (we'll call the points r1 and r2) should be similar to as follows (look for the line coordinates comment): -- Begin Code Sample onTick() -- converting angle to radians a = input.getNumber(channelNum) * 2 * math.pi end onDraw() -- screen sizing variables w = screen.getWidth() h = screen.getHeight() cx = w/2 -- x center cy = h/2 -- y center r = (cx+cy)*.333 -- a radius of about 67% of the screen size -- Line coordinates r1 = cx + r*cos(a) -- the point at cx, with direction r*cos(a) r2 = cy + r*sin(a) -- drawing our circle screen.drawCircle(cx,cy, r) -- drawing our line: screen.drawLine(cx, cy, r1, r2) -- Line from (16,16), center, to (27, 16), initially, on a 32x32 px monitor end -- End Code Sample Its a simple fix where you've used the "+" operator where it should be the "*" operator. By doing this, the script will correctly draw the line to the edge of the circle only. Yours would draw beyond the edge of the circle, which wouldn't be obvious on the 32x32 px monitor. Additionally, if we moved where we draw the circle your code will not correctly update the line showing where the radar is facing, it will generate a slight ticking effect and remain stationary. Not only does my code correctly orient the line, but it also draws only to the edge of the given circle. It also works if you want to adjust the placement of the circle on the screen (requiring an adjustment of where the line is drawn from, or the origin of the line) As a side note, most of your function blocks also should implemented in code via the Lua script block. It makes debugging a lot easier to figure out. I hope this clears a lot of the math up for anyone who tries to borrow his code and finds it does not work. Additionally, the math for correcting the orientation of the line to the radar is simply a conversion in radians, which wasn't explained in the video. A circle can be describe as 2π radians or 360 degrees. 2π/4 would be equivalent to 90 degrees. Subtract 2π/4 or (-1.5708) from your angle, if your radar is "behind". If it is "in front" of the line you've drawn, then add 2π/4 or (+1.5708).
I might've screwed up somewhere but your code isn't working for me no matter what I do to try to fix it I keep getting the error (from the screen itself): attempt to index a nill value ('global input')
I hate to be a downer, but isn't this radar very flawed? it can only detect one object at a time, is it possible to make it detect multiple objects at a time, instead? Also, if you turn it on, then off, then on again, it breaks, could you make it actually show the real angle, rather then a predicted one?
This is not a very insightful tutorial. Your clicking a lot of buttons without saying what your doing and your going way too fast for people who need a tutorial. This seems more like an explanation for people who already know how to do all this.
Hello, I am currently building a lidar, an ocean floor mapping for ships and it is based on the radar you made. I just change the radar into a laser distance sensor and other stuff and already detecting the distance where the laser is pointed but I can't figure out on having a multiple targets on screen. My current lidar right now can only display one target at a time because number values changes immediately. Well I am new Lua and can't figure it out. Can you create a tutorial for multiple targets? I am glad if you can help. Thanks!
I have a problem with the line; it seems to stay in one spot, but ever so often it spazzes out all over then back. Any idea what’s wrong? The red also doesn’t seem to appear. I did everything as you did.
Great video. I got my radar saving up to 10 targets. However, the range math was off if you're not close in. I just tied a Throttle in from 50 to 5000 for the range input and did td = (target range * 32)/total range. Works like a champ.
I think this video needs to be marked as not working. The thing is completely messed up and seems to only detect players. Even the workshop example does.
how in gods name do i invert the velocity pivot? Not matter how you turn it does magically change direction is there a button you can press that toggle the direction? Edit Ah you just press U, sure would be nice if the game showed that somewhere in the control menu
you go way too fast sometimes... Also try to have all the logic in view so it's readable whenever you're editing the microcontroller so we can identify mistakes.
i tried doing this but it doesn't show any vehicles or objects near the radar the screen works fine, am i missing something? I've triple checked all the code and it seams to be correct
OK HELP ME!! I have done everything that MrNJersey has done to the letter, in both script and microcontroller logic. The Radar turns, and the pings show up but the line on the screen does not move at all. It just shows the line pointing forwards, with the transparent triangle behind it. But the pings for target found don't show on the circle at all, they show up on the back edge of the triangle away from the line. So on my ship it always shows something off to my port side a few degrees off center, and I have been double checking myself against this video for days now.
I got a green circle, but adding the line gave me a blue screen and "draw error index a nill value (global 'screen') anyone know what that means. Edit - 5hrs later... I have a green line but my red dot just stays in middle no matter what. Guess il start again for the 5th time tommrow... So frustrateing. Edit 2 - just downloaded the exsample off the workshop and it dose the exsact same. Only shows a dot in the middle. Guess this a broken method now? Or can you only make a radar that detects you and nothing els?
This tutorial doesent work in 1.0 for some reason the dot does not display on the radar most of the time. However it works fine with the player. It will only display players and half the time the dot is in the incorrect position.
My screen keeps showing a line facing up that dosen't move at all and then the screen comes up with an error message a few seconds later, got any idea what I've done wrong? (I'm getting something that says there is something wrong with something in the "if t then screen.setColor(225,0,0) screen.drawCircleF(x4,y4,1) end" part) I got the circle working but the line still won't move ;/
Following this tutorial precisely, everything works until you added the memory registers. From then on the screen stopped displaying any red dots whatsoever. Is there something I overlooked?
I tried this and tested it when I got to the draw line part and I got the follow error: 13: Attempt to index a nil value (global ‘match’) I followed the video again, checked the script, rechecked all the logic connections, everything looks to be in order. Anyone know what’s going on?
@@MrNJersey i figured out what i did. It’s not surprising as I do this a lot. I went to fast and typed match.sin instead of math.sin and it took me an hour to see it. So this is a message to everyone who thinks too fast, READ YOUR SCRIPT SLOWLY.
why do you go (H+W)/4 and not just take H/2 ? the screen height is always the smaller or equal side; if your screen is not square; the circle will fit vertically and still be centered horizontally; where with (H+W)/4 you may end up with some weird incomplete circle ... like for example (64H+100W)/4=41 (which covers 82 ... so too small for the width; but too large for the height).
Just a heads up - i`ve done some math behind it and the "divide the distance by 32 for it to fit on the screen" is not right. If maximum 5000 meters is 32 pixels then 2500 meters would be 16 pixels - if you did /32 you would get 87.125 though. What you actually have to do is multiply the distance by 0.0064 or divide by 156.25 for it to accurately fit on the screen
Great video man, but you started by the system based on the lua script getting the monitor size by itself. so setting 32 into the logic will lock the setup to the 64x64 screen. Maybe set up an number output with half of the used screen like w1 = w /2 and output.setNumber(1, w1) so you can get the calculated size by the displayed monitor itself. combine this with @Dr Strangelove comment. And it works quite well.
I followed the directions and hooked everything up accordingly, the only problem is after editing the script, I cant update the microcontroller and I dont get the circle on my display. Any tips on what's wrong? Edit: I figured out my first problem, but now after I used the exact script it just says error on the screen. Lol this is more complicated than I thought. Also, it says like '(4) Nil value' on the screen yet I double checked everything to make sure it was exact
I know people probably won’t see this but I was wondering if it pinged enemy ships. Because it pinged a person so I was thinking blocks might get pinged as well if it did it would be so cool
Radar can rotate internally, without need to rotate whole casing, just set it to a=math.mod(a+s,1);y=a-0.5 , while s is speed of radar and y is yaw output for radar Whole thing you showed is nothing new, you could already do this with distance sensor (except radar is scanning just for objects, not enviroment) Also could you make that dot will stay on the radar until next sweep rewrite it?
Ah good one, Your correct in saying that this isnt new but nowhere have I said its new, However no video has been done on this and it was highly requested hence why it was recorded. The dot can stay on screen if you modify the delay.