#Player snaps to sides when is A and D clicked
1 messages ยท Page 1 of 1 (latest)
Send a video of what happens and then code
Can you show the player sprite transform
Is it 0, 0, 0
The sprite is parented I assume?
@cerulean charm
What happens is probably you flipping the axis on a parent. But child objects arent centered to the parent. So when they flip they move
A way around this would be to flip the sprite directly using SpriteRender.flip
Or to make sure the children are aligned correctly
What is sprite?
yes
i dont think so
In the hierarchy can you show the object
yeah so which of these child objects have a sprite
i think all of them
you need to make sure children transforms scale properly or you can use SpriteRenderer Flip
Also why do you set local scale again?
how i can do that?
sorry but can you try explain what is local scale? 
i am little bit dumb
its like the scale relative to the parent
I can show you an example, sec
lemme open unity
kk
Btw I recommend u create a new scene atm
so you can learn about local scales and parent scales
create a new scene with an empty object, create 5 cubes and child them to the empty object
like that?
Yea
So
Create a line with those squares
in any axis you like
make Square's position 1 , 0, 0 for example
make Square2's postion 2, 0, 0 etc
okay not bad
Uh so now move the parent
When you move the parent, you'll notice all the cubes
move relative to the parent
i see
so what I think your issue was
Delete all 3 cubes
leave only one
and move it away from the parent
if you flip the parent, it will appear on the other side
because the child isn't centered to the parent
the circle is the parent here, cube is child
Local Scale: 1
The circle flips
but the cube will move relative to that
do you get what I mean?
little bit
You can replicate it
Put the parent, the put a child object to the left of the parent
Now set the parent's transform scale on X to 1
Then set it to -1
Thats what you're doing in your code
tyt
Can you show the transform on ninja gameobject?
Set position to 0, 0, 0
The position you see in the inspector is relative to parent
it's not world transform
he is gone
Oh okay change only the X
to 0
It's probably because the Z axis is now equal or greater than camera
gone too
point is make the ninja the center of the parent
Im not sure whats happening there, but you can just do it manually
See those 2 red dots?
1st belongs to Player Gameobject
that's the center of Player, move the ninja to be closer to the center
oh... lmfao
ok done 0.0.0
okay test
same
What are you flipping, ninja or the parent?
sec
If you did it correctly, the center should be aligned with the parent
The first behavior is when the center is not aligned with the parent
But if you're struggling to align it you can just use spriterenderer flip
how can i do that?
how?
done
Show in code where you get it
sorry but i am confused
You can try flipping something simpler
Create a 2D circle
then create a script
Get the component of the sprite renderer
Then change the property
i fliped X and ninja doesnt moves
it doesnt move like doesnt move it just stays where it is ๐
i think i should delete this and start from scratch
I think you're trying to make something without understanding the environment
I would say play around with Unity and understand how it works
before making a game
Okay, Icetrack, thanks for your time. I really appreciate it
no worries
If you wanna understand like more about your issue
to replicate it just copy your previous code with flip
Put the parent object in the middle
and put the child object to the left
when you flip the parent object, the child object will be at the right
but if the parent and child object are on the same coordinates
Then it doesn't move when flipped
you can see it here