#collider not hold to navmeshagent

1 messages · Page 1 of 1 (latest)

nimble pecan
#

how to fix

#

@keen ivy npc collider dont get detected completely that why i added gui logging

keen ivy
#

Logging with gui is fine but log those necessary data

nimble pecan
#

yes but look

keen ivy
#

Instead of the less valuable "1, 2, 3, 4"

nimble pecan
#

when trying to raycast at npc im getting 0 on gui

#

meaning im not even hitting it so i have no data

#

and im 90% sure its fault of layermask

#

both default and pickup are pre defined ones

#

but npc is one i made

#

and is only used for this if

bright mica
#

Do you know how to use GetMask?

nimble pecan
#

well it does seem to work properly in editor

#

just not in game

nimble pecan
#

i did get multiple masks

bright mica
#

You don't + the bitmask.

nimble pecan
#

but since these are 0101 string they seem to work together no?

#

how else i can merge these 3 masks then

bright mica
#

|

nimble pecan
#

||? so i have to run 3 raycasts at once?

bright mica
#

bit or | is different from ||

nimble pecan
#

so LayerMask.GetMask("Default") | LayerMask.GetMask("Pickup") | LayerMask.GetMask("npc")

bright mica
#

And beside you can pass multiple layer names to GetMask

#

LayerMask.GetMask("Default", "Pickup", "npc") is fine

keen ivy
#

Log the result if you're unsure (that of those results and what you're expecting)

bright mica
#

If layer name is correct, 🙂

nimble pecan
#

it is because it work in unity editor

#

just not work in separate exe

keen ivy
#

We've heard that but it's best to go into this assuming everything can go wrong.

#

Ensure the layer detection is correct.

#

Ensure the ttt vector is as expected (a certain value).

#

At specific values of ttt, ensure it's entering the specific conditional branch (if statement).

nimble pecan
#

i dont get any vector in game

keen ivy
#

If all of this works in all cases then your issue will naturally resolve itself.

nimble pecan
#

because

#

i dont detect any collider

#

nothing is in place of npc

keen ivy
#

It's future suggestions

#

You ought to be mainly concerned about layers for now

#

Did the rest cast hit anything?

#

What did the ray cast hit (name)

nimble pecan
keen ivy
#

Does it have the necessary components

nimble pecan
#

gui text stays at 0

#

so raycast not even passes

keen ivy
#

Stop using those numbers as debugging info

bright mica
nimble pecan
keen ivy
#

Pretty sure it's common debugging 101 to log valued data ie layer being tested against, name of other object, collider, etc.

#

These should not be assumed.

#

So instead of logging 0, log what zero was supposed to verify.

nimble pecan
#

that player actually clicks

keen ivy
#

Log why it's zero

nimble pecan
#

raycast run on cliick

#

should i flick everything on in npc tab to check if raycast work then

keen ivy
#

All zero tells us is that raycast hit nothing.

#

Log why it hit nothing

nimble pecan
#

ah what should i add here

keen ivy
#

Instead of assuming there's no collider on the other object etc

#

Why not log the components of the ray cast to see if they're what you're expecting?

#

When I say log, I mean so with your text output

#

As you're not able to do so with Debug.Log in your build.

nimble pecan
#

i can in unity

#

but in unity everything works

#

just in game it doesnt

#

so i log on gui instead

keen ivy
#

Basically, figure out why it's zero.

#

Look at the parts of the ray cast and check if they're what's expected - likely not.

nimble pecan
#

on pc

keen ivy
#

Check if the other object is really at the correct location.

nimble pecan
#

i basically get direction where player is looking at

#

from its head

keen ivy
#

You're going to have to debug this as I can't do it for you.

#

My advice is "lot's of logs" or appended strings to be set to the text in your case.

#

What you and I see isn't what the computer sees. You need to see what the computer sees.

#

And see why it isn't seeing what you're seeing.

#

Trying to be clever and assume we know what the computer sees is the wrong approach. Just ask the computer what it sees till you figure out how to see it's way and make it see your way.

nimble pecan
#

ok it work now

#

i switched to different layer

#

prebuilt layer

#

so i was right that game only detects prebuilt layers

keen ivy
#

So why?

#

Log the non prebuilt layer and see what's the value. See why it's not liking it.

nimble pecan
#

i remember somebody said that game doesnt log names of the layers only numbers

#

so maybe if i would use layermask from number it would work

keen ivy
#

Not sure what you're saying but layers are just bit masks

#

They're all numbers ultimately

#

Instead of guessing log what the computer sees

nimble pecan
#

they say it doesnt log this name

#

only its value

#

so i would have make bit mask from int

keen ivy
#

Logging binary is fine as we can all read binary?

nimble pecan
#

no i mean not logging but game doesnt store it at all

#

gets vaporized on build

keen ivy
#

I don't believe so

nimble pecan
#

well that what they said

keen ivy
#

You're likely misunderstanding stuff

nimble pecan
#

so how would bit mask out of numbers look like

nimble pecan
keen ivy
#
"A" = 0001
"B" = 0010
```Logging `A | B` will not give you a valid name but it'll definitely give you a value.
#

In my case A | B would give you 3 or rather 0011

nimble pecan
#

nono i wanted replace getmask to use int instead of string

keen ivy
#

More variables and rooms for mistake

nimble pecan
#

i need test that as that what they talked about to not use strings with layermasks

keen ivy
#

Good luck experimenting with bit masks

nimble pecan
#

it does work on reserved layer so its not reading my custom layer

#

probably because it not included in raycast

#

that why it dont even log 1

keen ivy
#

That's a lot of assumptions

plucky spire
#

don't need to guess if you use debug.logs with relevant contents 😄

keen ivy
#

Prove it all. But just to be clear, you're better off seeing what the computer sees and work from bottom up instead of assuming stuff. Seeing the flow isn't enough, you need to see exactly what it's seeing/reading/evaluating.

plucky spire
#

troubleshooting is half guessing half testing - a theory + solution is prone to x-y problems - prove your theory first

#

before trying to fix it

#

an x-y problem is when you misinterpret the cause of the problem and try and solve it anyways

keen ivy
#

My interpretation: Prove that is not reading your custom layer before using some other layer solution. ie What is your custom layer's value? What's it being evaluated against? Why raycast doesn't like it.

plucky spire
#

I bet his attention is lost, having solved the "problem" 😛

nimble pecan
#

no it was actual thing