#How to make blindspot

1 messages · Page 1 of 1 (latest)

high compass
#

Raycast

#

Youd just raycast outwards from the monkey, and then shape the circle based off of the raycast lengths.

static cedar
#

Idk how to shape the circle

#

Also

#

Im making it sphere

high compass
#

You could technically do get parts in part method and reverse raycast to the tower.

static cedar
#

That wouldbt change anything tho

#

Cuz im trying to shape the circle

#

Ik the raycast part

#

Js the visual part is where i struggle

high compass
#

ok

#

let me hop in studio to show you what i mean @static cedar

high compass
high compass
#

For starters, you'd need to do raycasts to each of these objects vertices.

#

So: To start you'd do getpartsinpart, which will return all of these blocks that are in the way. You can even use a collision group to handle the raycast parameter if you want to do so.

#

Each of these would than raycast to the tower

#

(so on so forth)

#

from here you actually have 2 things. For starters, you have the tower's vision of the block, but also what they can see beyond the block. Lets take the right block for

#

From here, you actually can create a negative space for what the tower can and cant see.

#

The blue being the raycast, the red being a negative of the raycast, and then the yellow being what the tower can't see

static cedar
#

Uhuh uhuh

#

So

#

How do i shape the circle then

high compass
#

Now, there may be a less barbaric method, but what I would do is create unions for the turret's range, depending on the blocks that block the vision of the turret.

#

ik its hard to see

static cedar
#

Hmm

#

K

high compass
#

and if we change the collision fidelity with a union...

#

bamo

#

it wont detect anything in that gap we just made since it's not in the part.

static cedar
high compass
#

What's what

#

This weird appearance of the union?

static cedar
#

Yes

high compass
#

That's a plugin called Mesh Optimization Tools by Maximum_ADHD

#

but overall that's how I would do it

#

more than likely there are better, more efficient, less mathematical heavy ways of doing it, but this is just the solution I came up with.

high compass
#

they more than likely just fire a constant number of raycasts

#

but they still probably do use the getpartsinpart method

#

raycasts are extremely performant. You could do thousands of them a second without noticing a difference.

static cedar
high compass
#

with method 2, youd want to fire a raycast from all towers to all the tower's get parts in part

static cedar
#

how do i find the corner tho?

#

like the vertices

high compass
#

with method 2 you wouldnt need to do that

static cedar
#

so first

#

im gonna check parts in the range

#

2nd

#

fire a raycast that is aimed at the target

#

3rd

#

check if target is visible or not

#

4th

high compass
#

OKay

#

so

#

lets just do it like this

#

you put all the towers in a folder

#

for i, v in pairs(folder) do

#

for each tower, you want to check the type of tower. If it's an attacking tower, you want to specify.

#

if tower:GetAttribute("Type") == number then

#

Then, get the range of the tower

#

local range = tower:GetAttribute("Range")

#

then, getpartsinpart of the tower's range. (in this case a circle)

#

For the getpartsinpart, youll want to ignore the tower itself, and also obstacles. Reason being is because you dont care to self check itself if it exists inside it's range. You only want the targets.

#

From there you want to check each target in it's range.

#

Firing a raycast starting from the tower's position, with a lookvector to the entity, with a range of the tower's range

high compass
#

If the raycast is interrupted by a blockade, then you recheck until the turret finds a target to hit.

high compass
#

use a repeat until loop

static cedar
#

wouldnt it just hit the same target

high compass
#

You'd want to fire through all the get parts in part

#

until you find one to hit

#

then you'd use a return/break once you found one to hit

static cedar
#

so im checking for targets here

high compass
#

yes

static cedar
#

but what if theres no targets yet

#

in the circle

high compass
#

If the raycast doesnt find the target, then you assume the target is being obstructed.

#

You'd just have a one line return

static cedar
#

oh okok i get it

high compass
#

"getpartsinpart,
if #(getpartsinpart) == <1 then return end"

static cedar
high compass
#

this explains raycasting to a target

#

if the raycast ends before it reaches it's target, that means that the view is obstructed

static cedar
#

ok

#

so how does the unionizing part work

#

like showing the blindspot

#

since thats my goal

high compass
# static cedar What does this do

if the number of things inside of getpartsinpart is less than 1, return the script, which essentially stops the previous if statement. Stopping further code.

#

🤦‍♂️

#

Im explaining the second method

#

which is more efficient

#

the first method, the union one, is too complicated

high compass
#

If there's anything you dont understand of this, make a new help post asking about that specific thing

static cedar
static cedar
high compass
#

You would have to do the aforementioned thing.

#

although you would still use getpartsinpart.

#

and to be honest, unioning something every frame is going to be extremely rough

#

but i have no idea on performant it is

static cedar
high compass
#

.

#

You are asking 2 different questions.

#

The question you just asked is unrelated to the question you asked previously

static cedar
#

im asking 1 question tho?

high compass
#

1st method I talked about is only for personal viewing.

#

2nd method I talked about is what the actual code would do to check to see if it can hit a target or not

static cedar
#

k imma start a new one

#

im lost

high compass
#

xD