#Pathfinder avoids walls - finds nearest

215 messages · Page 1 of 1 (latest)

clever basalt
#

Code Block 1:

SET Player.SelIndex 0        ; init player selection
SET M0.Pos.Y 16              ; move speed
SET M1.Rot.X 4               ; turn strength
SET M1.Rot.Z 0
SET M1.Rot.Y 0               ; mode: 0 = go, 1 = follow
SET M0.Pos.X Bot.Pos.X       ; anchor/start X
SET M0.Pos.Z Bot.Pos.Z       ; anchor/start Z
SUB R0 Player.Pos.X M0.Pos.X
SUB R1 Player.Pos.Z M0.Pos.Z
SET M0.Rot.X R0              ; m-line dir X
SET M0.Rot.Z R1              ; m-line dir Z
MUL R2 R0 R0
MUL R3 R1 R1
ADD R2 R2 R3
SQRT R2 R2
DIV M1.Pos.Y 1 R2            ; inverse m-line length
SET M1.Pos.Z 0.25            ; m-line tolerance
SET M1.Pos.X 0               ; stored hit distance

LABEL Loop
SET Player.SelIndex M0.Col.R
SUB R0 Player.Pos.X M0.Pos.X
SUB R1 Player.Pos.Z M0.Pos.Z
SET M0.Rot.X R0
SET M0.Rot.Z R1
MUL R2 R0 R0
MUL R4 R1 R1
ADD R2 R2 R4
SQRT R2 R2
DIV M1.Pos.Y 1 R2
SUB R0 Player.Pos.X Bot.Pos.X
SUB R1 Player.Pos.Z Bot.Pos.Z
ATAN2 R2 R0 R1
MUL R3 R0 R0
MUL R4 R1 R1
ADD R3 R3 R4
EQUAL R4 M1.Rot.Y 0
IF R4 MODE_GO
GOTO MODE_FOLLOW

LABEL MODE_GO
IF F.Trg.Active HIT
SUB R0 F.Pos.X Bot.Pos.X
SUB R1 F.Pos.Z Bot.Pos.Z
ATAN2 R5 R0 R1
SUB R0 R2 R5
ADD R0 R0 180
MOD R0 R0 360
LESS R1 R0 0
IF R1 GO_ADD360
GOTO GO_READY
LABEL GO_ADD360
ADD R0 R0 360
LABEL GO_READY
SUB R0 R0 180
SUB R1 0 R0
LESS R4 R0 0
IF R4 GO_NEG
SET R1 R0
LABEL GO_NEG
LESS R4 R1 3
IF R4 MOVE
MUL R1 240 M1.Rot.X
MUL R1 R1 DeltaTime
LESS R4 R0 0
IF R4 GO_TURN_L
ADD Bot.Rot.Y Bot.Rot.Y R1
GOTO MOVE
LABEL GO_TURN_L
SUB Bot.Rot.Y Bot.Rot.Y R1
GOTO MOVE

LABEL HIT
SET M1.Rot.Y 1
SET M0.Pos.X Bot.Pos.X
SET M0.Pos.Z Bot.Pos.Z
SET M1.Pos.X R3
GOTO Loop

LABEL MODE_FOLLOW
IF F.Trg.Active AVOID_FRONT
GOTO CHECK_LEAVE

LABEL CHECK_LEAVE
SUB R0 Bot.Pos.X M0.Pos.X
SUB R1 Bot.Pos.Z M0.Pos.Z
MUL R2 M0.Rot.X R1
MUL R4 M0.Rot.Z R0
SUB R2 R2 R4
MUL R2 R2 M1.Pos.Y
SUB R5 0 M1.Pos.Z
GREATER R6 R2 R5
LESS R7 R2 M1.Pos.Z
AND R6 R6 R7
SUB R0 F.Pos.X Bot.Pos.X
SUB R1 F.Pos.Z Bot.Pos.Z
SUB R4 Player.Pos.X Bot.Pos.X
SUB R5 Player.Pos.Z Bot.Pos.Z
MUL R0 R0 R5
MUL R1 R1 R4
SUB R0 R0 R1
LESS R7 R0 0
AND R6 R6 R7
IF R6 LEAVE

NOT R0 L.Trg.Active
IF R0 WF_SEARCH
GOTO WF_PRESS

LABEL WF_PRESS
MUL R0 18 M1.Rot.X
MUL R0 R0 DeltaTime
SUB Bot.Rot.Y Bot.Rot.Y R0
GOTO MOVE

LABEL WF_SEARCH
MUL R0 520 M1.Rot.X
MUL R0 R0 DeltaTime
ADD Bot.Rot.Y Bot.Rot.Y R0
GOTO MOVE

LABEL AVOID_FRONT
MUL R0 720 M1.Rot.X
MUL R0 R0 DeltaTime
SUB Bot.Rot.Y Bot.Rot.Y R0
GOTO NO_MOVE EB Spark

LABEL LEAVE
SET M1.Rot.Y 0
GOTO Loop

LABEL MOVE
SUB R0 F.Pos.X Bot.Pos.X
SUB R1 F.Pos.Z Bot.Pos.Z
ATAN2 R5 R0 R1
SIN R0 R5
COS R1 R5
MUL R0 R0 M0.Pos.Y
MUL R1 R1 M0.Pos.Y
MUL R0 R0 DeltaTime
MUL R1 R1 DeltaTime
ADD Bot.Pos.X Bot.Pos.X R0
ADD Bot.Pos.Z Bot.Pos.Z R1
SLEEP 0
GOTO Loop

LABEL NO_MOVE EB Spark
SLEEP 0
GOTO Loop

**Code Block 2: **

LABEL Get NearestV2 EB
SET R6 1e+20
SET R4 255
SET R7 0
LABEL Loop
LESS R5 R7 Player.Count
NOT R5 R5
IF R5 Done
SET Player.SelIndex R7
EQUAL R5 Player.Valid 1
NOT R5 R5
IF R5 Next
SUB R0 Player.Pos.X Bot.Pos.X
SUB R1 Player.Pos.Y Bot.Pos.Y
SUB R2 Player.Pos.Z Bot.Pos.Z
MUL R0 R0 R0
MUL R1 R1 R1
MUL R2 R2 R2
ADD R3 R0 R1
ADD R3 R3 R2
LESS R5 R3 R6
IF R5 Update
LABEL Next
ADD R7 R7 1
GOTO Loop
LABEL Update
SET R6 R3
SET R4 Player.Id
GOTO Next
LABEL Done
SET M0.Col.R R4
SLEEP 0
GOTO Get NearestV2 EB

if it doesnt work, try giving it every connection input and outpuit possible

**Setup Guide & Tutorial on my Youtube: **
https://youtu.be/j2FzPHlohhs?si=YBtemlh_ebwq66vu

This tutorial will guide you through how to set up your very own path finder.

Code can be found in the discord:
https://discord.com/channels/329735841067040771/1480716187288731769

Code used in this video:
Code Block 1: (pathfinding)

SET Player.SelIndex 0        ; init player selection
SET M0.Pos.Y 16              ; ...
▶ Play video
#

Pathfinder avoids walls - finds nearest

heavy socket
#

How.

clever basalt
#

Code Block 1:

Bot
Bot.Pos.X
Bot.Pos.Z
Bot.Rot.Y

Player
Player.Pos.X
Player.Pos.Z
Player.SelIndex

Triggers

  • forward trigger
    F.Pos.X
    F.Pos.Z
    F.Trg.Active

  • left trigger
    L.Trg.Active

Memory Blocks

M0
M0.Pos.X
M0.Pos.Z
M0.Pos.Y
M0.Rot.X
M0.Rot.Z
M0.Col.R

M1
M1.Rot.X
M1.Rot.Y
M1.Pos.X
M1.Pos.Y
M1.Pos.Z

Code Block 2:

Bot
Bot.Pos.X
Bot.Pos.Y
Bot.Pos.Z

Player
Player.Pos.X
Player.Pos.Y
Player.Pos.Z
Player.Id
Player.Count
Player.Valid
Player.SelIndex

Memory Blocks

*M0
M0.Col.R

watch the video to set it up

heavy socket
#

We finna get too complex

clever basalt
#

does it not let you view it?

heavy socket
clever basalt
#

its set to unlisted

heavy socket
#

Did you do it just now?

clever basalt
#

nah a while ago

#

try this link maybe?

heavy socket
#

Now it works

clever basalt
#

epic

#

new link worked or old one did

heavy socket
#

New link

ionic aspen
#

Tysm

steep gorge
#

he's spinning in one place

#

help

clever basalt
steep gorge
#

ya

clever basalt
#

i can help set it up if your on

steep gorge
#

i am, join pls

#

😭😭

#

its public

#

u good?

clever basalt
#

temporarily something is broken I believe unless anyone else gets it to work let me know

tawny linden
#

Does it use an actual pathfinding algorithm or just moves around till it can reach you?

carmine frost
#

idk i think both

clever basalt
clever basalt
#

do not have start active on, a trigger must be connected to SPECIFICALLY to code block 1 (longer one) first and then to code block 2 (shorter one)

#

imma see if I can fix that lol

#

nah

#

wait

#

what the flip

#

I basically gave it every input output register that was available and it just worked shrug

steep gorge
#

Wanna give to me?

clever basalt
#

issue is that it break when you prefab it 😄

#

no idea why

#

I can try to reset it up for you again but this time like how I did with this one ig

clever basalt
steep gorge
#

Gimmie 5 mins, I'm boutta have sum kiwi

#

@clever basalt

#

wanna hop on?

clever basalt
steep gorge
#

Ur server?

carmine frost
#

prob his server

steep gorge
#

good point

clever basalt
clever basalt
#

Imma make a better one

quasi dirge
#

how do i change the speed

clever basalt
#

its what you want to change

quasi dirge
#

ok thx

clever basalt
#

okay I made a better one but I am going to make a video for it so it wont be released til tmr or day after tmr

carmine frost
#

can i see it, basically do its job

neon canyon
icy plaza
#

oh nvm

strong current
#

yoink

neon canyon
north kettle
#

How to change it's speed?

clever basalt
#

higher = faster

tulip loom
#

Bro stop copying me idea

#

I totally made this code

neon canyon
#

@clever basalt

#

Wait js fixed it because the pivot reset

#

@clever basalt

visual musk
#

@clever basalt

neon canyon
visual musk
#

ok thanks

#

i tried

#

doesnt work

#

still the same result

#

@neon canyon help

neon canyon
#

@visual muskmmake sure all triggers are the same size and engulf the bot. Takes a couple tries to work,

visual musk
#

ok ill try

#

is it like this?

#

@neon canyon

neon canyon
neon canyon
visual musk
clear nymph
#

@clever basalt Why it saying Error @16.2: Division by zero

clear nymph
clever basalt
#

Cant see your triggers so idk id you set up wrong

clear nymph
neon canyon
#

@clever basalt also where's your updated code?

clever basalt
#

waiting for crescent to edit the video for me

#

code is done, just sent him the video a couple hrs ago but he might not work on it till tmr

clever basalt
#

perhaps thats the issue no?

#

there are some things wrong with that. new version will resolve everything I think

neon canyon
fickle hearth
#

Mb I didn't see it had been answered lol

neon canyon
neon canyon
clever basalt
#

I saw

neon canyon
#

How I fixy

clever basalt
#

Oh well, wait til the next one bc it's going to be the latest and greatest

neon canyon
#

When is that

#

You said it was supposed to be yesterday you would make the vid

#

Or new vsr

neon canyon
#

Oh okay

#

Is it going to be Public or unlisted?

zinc oak
#

i fixed something but now its just spinning

#

nvm its broken again

tulip loom
#

I’m gonna make a sorta betterish one tomorrow.

naive sable
twin pecan
#

Yo @clever basalt could you help me set it up in game? I’m having trouble understanding the set up so dm me please and I’ll tell you when I can get on

naive sable
silver marsh
neon canyon
#

@clever basalt so we just not sending tut and new code 😭

stable rune
naive sable
#

I SAID ERROR

stable rune
#

ok

naive sable
#

Lol

stable rune
#

hey

#

i

#

need

#

some

#

help

#

do u know how to make a mirror reflection

naive sable
#

Yeah

stable rune
#

can u send me a code with it or u cant?

naive sable
#

Um there's a snippet for that

stable rune
#

show me it pls

neon canyon
clever basalt
#

which is end of month

stable rune
neon canyon
tulip loom
#

@clever basalt how does it detect who's the nearest player and moves to them?

neon canyon
#

@clever basalt it's not shared no more

neon canyon
hasty ice
#

@clever basalt does it work now

fickle hearth
#

Simple math

#

Like if you want to mirror a point on the X axis just do
Set Y Y
Set Z Z
Mul X X -1

random ibex
#

It works on lucky occasions when you get close enough

#

Overall code is a 8/10

Works well, but does require you to find the monster in a maze

random ibex
#

?

neon canyon
#

It has gravity

#

And finds nearest

random ibex
#

Can it go up slopes?

neon canyon
#

But uhh it kinda breaks when it's chasing you and you restart

neon canyon
random ibex
#

Holy crap

#

Thats crazy

neon canyon
#

Just it can't go up slopes more than 60 degrees for some reason because it used to be able to go up 90

random ibex
#

Thats fine I use 45°

neon canyon
#

Yeah but for some reason uhh it kinda breaks with pyramid shape

random ibex
#

makes sense ig

neon canyon
#

And cone

random ibex
#

Is there a thread in this channel?

neon canyon
random ibex
#

You should make one for this

#

Well

#

For your code

neon canyon
random ibex
#

Current one too op?

neon canyon
#

And not putting it in a map

neon canyon
random ibex
#

Damn

neon canyon
#

You know those people bouta be stealing the map if I post

random ibex
#

True

neon canyon
# random ibex Damn

It's kinda like the cheeseball one but it uses the physics to go up and down slopes

random ibex
#

Fake physics or real physics?

neon canyon
random ibex
#

Ah

neon canyon
#

Physics is just measuring for height and stuff

random ibex
#

Oh I see

neon canyon
#

I'm trying to find a way to just use fake physics though

random ibex
#

Fake physics like bounce up and down constantly

neon canyon
#

Also idk why but I found a way to make it kinda have a idle animation like a Roar before it pathfinds

neon canyon
random ibex
#

Impossible!

neon canyon
neon canyon
random ibex
#

Send a vid?

neon canyon
#

But maybe I'll send

random ibex
#

Oh

neon canyon
#

Still working on it but ok

random ibex
#

Its insane how 1 block changed the entire game

neon canyon
#

Working on the most useless thing btw

random ibex
neon canyon
#

Anyways it's very delayed with the physics part

#

When shared

#

Okie bye

random ibex
#

Cya

neon canyon
#

I'll stop the yap

clever basalt
#

college almost over

rotund phoenix
neon canyon
blissful gate
#

What is M0 and M1

neon canyon