#what if i don t have a facingdirection

1 messages · Page 1 of 1 (latest)

split tapir
#

how would i implement a facingDirection variable?

#

here is my code

storm canyon
#

just set it to transform.right or whatever

#

then it will always stay facing the same way as your object

split tapir
#

but i don't transform.rotate my player

storm canyon
#

how is your player rotating?

split tapir
#

i use animations to fake rotation

storm canyon
#

why?

split tapir
#

its like a topdown thign

storm canyon
#

ah

split tapir
#

*topdown

#

2d

#

like zelda

storm canyon
#

then just make a variable and set it to your direction whenever you set your animation

willow dock
#

Many ways to track direction. Best way to do that when you are directing animation, or animation itself can send events through animation actions on specific frame playing.

split tapir
#

so maybe i could make a function that defines the direction the player is facing, and make a parameter that is passed through durign an animation event

#

oh but i can't pass a vector2 in an animation event

tender storm
#

You have one

#

it's called input

split tapir
#

i think maybe using lastMoveDirection would be better

#

maybe

#

idk

tender storm
#

or just

Vector3 dir = facingLeft ? Vector3.left : vector3.right;```
split tapir
#

what does that do?

tender storm
#

picks left or right depending on which way you're facing

#

but wait

#

you're inverting the scale

#

so you can just use transform.right;

split tapir
#

i also need it to work up and down

tender storm
#

then input

#

is already your facing vector

split tapir
#

alright

#

so then

firepoint.position = transform.position + input
#

.position

#

wait

#

no

#

my brain is dying right now im so tired 😭

tender storm
#

why would you set the position

split tapir
#

wait what would i write

#

firepoint is a transform and input is a Vector2

#

if anyone sees this and feels liek suggesting something, please do, i greatly appreciate

#

i gotta go to sleep lol

tender storm
split tapir
#

thank you brother 🙏🏾

split tapir
#

and i want to make firePoint = facingDirection

#

wouldn't the firePoint position always be (0,0)?

#

because input gets updated every frame

#

so if i stop moving input will = Vector.zero which will make the firepoint.right (0,0)

#

im honestly just super confused now

tender storm
#

so that it stays in whatever direction it was before that

split tapir
#

that is just the lastMoveDirection vecto2

#

*Vector2

#

so i used that

#

and now it's just rotating the firePint

#

wait

#

im dumb just a sec

split tapir
#

huh

#

ok so what's happening is that its rotating the firePoint but the position isn't changing at all

tender storm
#

why do you need the position to change

split tapir
#

i want to make it turn with the player right?

#

the fire point is a bit in front of the player

#

because thats where i want the projectiles to spawn

#

i don't want them to spawn on top of the player

#

how would i get the firePoint to be in front of the player?

#

would it be firePoint.right = lastMoveDirection + transform.position?

#

i figured it out