#walking
1 messages · Page 1 of 1 (latest)
yes
there are several directions here, and i can't tell which one you're using
look
when i go left
it goes left
but when im facing left
and i hut a
it goes left again
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?)
backwards
huhh?
wdym
like it rotates?
the player turn left
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
um..
first...i take the forward direction of the player..then i make that the forward direction for the camera
let me explain two common ways to control a third-person game
can u vc?
no.
kk
one: the player's rotation is based on which way the player is moving. you always face the direction you are moving.
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
not that
the first one
like fortnite
nono
Okay. In that movement style, the camera controls which way you move.
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.
i think u still didn't understand
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
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
probably
kk cy
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
hmm
that's the type of game i wanna make
but a bit different
ykw
screw it
actually
did u see the vid i sent>
yes, but i couldn't really gather any information from it
why? this seems extremely unintuitive for a game where you control a humanoid character
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
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
tell me ill try
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
ill tell u my game idea
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)
error\
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
oh ..k
The direction you move will change as the camera rotates. Not ideal if you don't directly control the camera.
wait
what if i move the camera instead
cuz that stuff is confusing
wait ill see yt tutorial on that
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.
yo i saw a tutorial
it doesn't work
idk why
;-;
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
heres the code
@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
seems reasonable!