#Need help!

1 messages · Page 1 of 1 (latest)

coarse smelt
#

My player continuously moves without any key inputs.

hard sky
#

How do you know there's no input? Have you logged the input yet?

coarse smelt
#

I still am trying to figure out which code is used to actually get the object, Then find its values and show them

hard sky
#

Get what object

coarse smelt
#

Well i have the player that moves. But i need the moveDirections values to see why my player moves without any key inputs

torpid shale
#

what's that got to do with getting an object

coarse smelt
#

scrap the object part

torpid shale
#

lmao

torpid shale
coarse smelt
torpid shale
#

logging is about the simplest thing in unity

coarse smelt
torpid shale
#

are you setting it somewhere?

coarse smelt
#

Yup

torpid shale
#

pretty self explanatory

hard sky
coarse smelt
#

I have it in script but i dont know how to make the debug log find the values of moveDirection

hard sky
#

Just log it after you get it

hard sky
#

That's it

#

That's the line

coarse smelt
#

So is it debug log with literally just moveDirection in it?

hard sky
#

You just put the variable in the parenthesis

coarse smelt
#

oh.

hard sky
#

That's why I said to log moveDirection like an hour ago

coarse smelt
#

It gives an error: Cannot use local variable moveDirection before its declared

coarse smelt
hard sky
#

So don't use it before it's declared

#

I also said to do it after you set it

coarse smelt
#

Got the values i think

#

so it moves 0.71 Y and -0.71 X?

#

without the inputs of a key pressed

#

What do we do from here?

torpid shale
#

vector3's are X, Y, Z

coarse smelt
#

Ya srry

#

But what do i change so it stops moving?

hard sky
coarse smelt
#

The values change on direction

hard sky
#

It's moving because you've got move input

coarse smelt
torpid shale
#

how are you setting moveDirection

#

is it based on inputs?

coarse smelt
#

I also have a WalkSpeed variable thats always at 5

hard sky
coarse smelt
#

So thats probably the real reason

torpid shale
#

what is your code doing

coarse smelt
#

Well i can move other directions

#

Like forwards

#

and left

#

but s and d are kinda not working

coarse smelt
#

Ill show the movement

#

code

#

Or ill give you the full code

torpid shale
#

up to you

coarse smelt
#

Check it out

#

See if anythings weird

torpid shale
coarse smelt
#

K ill log those

shell fractal
# coarse smelt K ill log those

Have you done !learn yet? If not, you really need to stop everything and do the essentials pathway AND the junior programmer pathway before continuing. It will save you so much time

jolly veldtBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

coarse smelt
#

So vertical movement is forever at -1 and when W is clicked it changes it to 1 which then moves forward

#

So instead of forever -1 i need 0

torpid shale
#

sounds like your input system is the problem not your code

coarse smelt
#

Do i fix it in Input Manager?

torpid shale
#

yup

coarse smelt
#

Do you see the problem?

#

Update!

#

Player does not move off spawn

#

but when key is clicked his vertical movement forever moves forward

#

Is that code problem or input still?

#

He forever moves in every direction actually

#

last key clicked the player doesnt stop going that direction until it is cancled out

#

I FIXED IT!

#

TY SO MUCH GUYS!