#walking

1 messages · Page 1 of 1 (latest)

plush abyss
#

.

main drum
#

yes

plush abyss
#

there are several directions here, and i can't tell which one you're using

main drum
#

look

#

when i go left

#

it goes left

#

but when im facing left

#

and i hut a

#

it goes left again

plush abyss
#

every direction you use when desciribing this problem should be from the camera's perspective, so that there is no ambiguity

#

so, the camera is facing forward

#

always, because we're looking from the camera's perspective

#

the player is facing left

#

you hold A

#

which direction do you want to move (again, from the camera's perspective?)

plush abyss
#

okay

#

my only question then: How does the player rotate?

main drum
#

wdym

#

like it rotates?

plush abyss
#

yes

#

how do you make the player turn?

main drum
#

the player turn left

plush abyss
#

how do you make that happen?

#

WASD all just make you walk, without rotating you

main drum
#

THATS EXACTLY WHAT IM ASKING BRUHHH

#

HOW DO I MAKE THAT HAPPEN

plush abyss
#

no, I'm asking you how you intend for the player to be able to do that

#

i'm not talking about code

#

you are designing the game here

main drum
#

first...i take the forward direction of the player..then i make that the forward direction for the camera

plush abyss
#

let me explain two common ways to control a third-person game

main drum
#

can u vc?

plush abyss
#

no.

main drum
#

kk

plush abyss
#

two: the player's rotation is based on which way the camera is facing. you can strafe and walk backwards.

#

the first one is how you move in a lot of action-adventure games

#

the second is how you move in a third-person shooter

main drum
#

the first one

#

like fortnite

#

nono

plush abyss
#

Okay. In that movement style, the camera controls which way you move.

main drum
#

like um...

#

wait lemme think

plush abyss
#

When you hold W, your character runs in the direction the camera is facing

#

this is very intuitive

#

It doesn't matter which way the character is currently facing. They turn to face the direction they are moving in.

#

That's what the code we were talking about earlier did. It rotated the character towards their movement direction.

main drum
#

i think u still didn't understand

plush abyss
#

The problem is that you currently don't check which way the camera is facing. A and D always move you on the X axis, and W and S always move you on the Z axis

main drum
#

wait ill come back in 15 mins

#

i gotta eat and take abreak

#

will u be then??

#

i have been doing this 3 hours now

plush abyss
#

probably

main drum
#

kk cy

plush abyss
# main drum i think u still didn't understand

A movement system where the direction the player is facing controls which way you move would be very confusing. The only game I know of that does that is Brigador, a vehicle combat game.

#

it's a very deliberate design choice, because you're piloting tanks and mechs and stuff

main drum
#

that's the type of game i wanna make

#

but a bit different

#

ykw

#

screw it

#

actually

#

did u see the vid i sent>

plush abyss
#

yes, but i couldn't really gather any information from it

plush abyss
main drum
#

look closely

#

when the player goes behind the camer

#

the whole wasd changes

#

there

#

s is for w

#

w is for s

#

thats what im saying

plush abyss
#

okay, so you do want movement to depend on camera rotation

#

you keep flip-flopping on this

#

you want the character to move away from the camera when you hold W

#

it's pretty simple to make this happen, fortunately

main drum
plush abyss
#

currently, you just do this

#
        var horizontal = Input.GetAxis("Horizontal");   
        var vertical = Input.GetAxis("Vertical");

        var movement = new Vector3(horizontal, 0, vertical);
#

instead, try this

main drum
#

ill tell u my game idea

plush abyss
#
var horizontal = Input.GetAxis("Horizontal") * Camera.main.transform.right;
var vertical = Input.GetAxis("Vertical") * Camera.main.transform.forward;

var movement = horizontal + vertical;
float magnitude = movement.magnitude;

movement = Vector3.ProjectOnPlane(movement, Vector3.up);
movement = movement.normalized * magnitude;
#

try this out

#

This uses the forward and right directions of the camera

#

The second half is to get rid of any up-and-down movement

#

you don't want to walk into the air or into the ground

#

it flattens the vector so that it's flat on the ground, then makes sure it has the correct length

#

(since the new, flat vector will be a little shorter)

main drum
#

error\

plush abyss
#

However, if you do this alongside a camera that follows you around, then it will also be very confusing

#

oh right:

#

fixed it

#

I forgot to access the transform

main drum
#

oh ..k

plush abyss
main drum
#

wait

#

what if i move the camera instead

#

cuz that stuff is confusing

#

wait ill see yt tutorial on that

plush abyss
#

I would suggset following a tutorial, yes.

#

I still can't quite tell what kind of movement you want.

#

Find a tutorial that shows the same kind of controls you're thinking of.

main drum
#

kk

#

u can close thid thread now

#

wait

#

nvm nvm

#

close it

main drum
#

yo i saw a tutorial

#

it doesn't work

#

idk why

#

;-;

#

heres the code

#

@plush abyss

plush abyss
#

well, you didn't really change anything

#

you added a thing that sets the position of the character in LateUpdate

#

but you already have a character controller

#

i don't know what you expected to change

plush abyss
#

seems reasonable!

main drum
#

:>

#

except the building come in between

#

ill fix it :>

#

ik now

#

nvm i cant

#

tell me how to make the camera come closer when an object in between :>