#Camera and movements issue

1 messages · Page 1 of 1 (latest)

prime cove
#

I have created a player with CharacterBody2D added CollisionShape2D and AnimatedSprite2D to it also added touch screen button for touch controls. And everything was working perfectly until I added Camera2D to the player.
After adding it I am facing this issues.

  1. The camera won't follow the player no matter what I do.

  2. If I try to enable the camera from script in ready function using func _ready():
    $Camera2D.make_current()
    The player will get stuck in a single spot but the movement and animations work.

  3. If I force to manually using
    $Camera2D.position = position in physics process the movements and animations are reversed but the camera won't follow the player.
    Finally if delete the Camera2D everything works fine.

flat crystal
#

The player will get stuck in a single spot but the movement and animations work.
are there any objects other than the player in the scene?

prime cove
flat crystal
#

in the scene that you're playing

#

just anything that you can see other than the player

prime cove
#

I have a world scene added player to it as a child in it nothing except player

flat crystal
#

add something to it

#

just any visible object

prime cove
#

Hmm u mean add a sprite or something to the word scene?

flat crystal
#

yea

prime cove
#

OK I will please wait

flat crystal
#

now try moving around

prime cove
#

Nope same thing

flat crystal
#

is the camera a child of the player?

prime cove
prime cove
flat crystal
#

are you sure your speed variable isn't set to 0

prime cove
#

Maybe please check this

flat crystal
#

press on the instance of the player in the scene

prime cove
#

It's 300

flat crystal
#

in player.tscn or in world.tscn

prime cove
#

Player

flat crystal
#

check it in world.tscn

prime cove
#

World I did added any script to it

#

Only for player

flat crystal
#

check the instance of the player in world.tscn

prime cove
#

Wait

#

I did it checked and re added again but same issue

#

I will send the project zip can please see tell me where it went wrong

flat crystal
#

what is the console printing while you're moving?

prime cove
#

I did debugging it player position numbers are changing and physics_process is running

flat crystal
#

the position is changing?

prime cove
#

Ya In debugger but when I try to move it gets stucks but movements running turning and animations works like in the video above

flat crystal
#

the sprites you added aren't children of the player right?

prime cove
#

No

#

I attached it

#

To the player like everyone

flat crystal
#

can't open it right now sorry

prime cove
#

OK please do when you have time

prime cove
flat crystal
#

did you add a visible sprite inside of the player's view?

prime cove
#

Yes AnimatedSprite2D and animated them to

flat crystal
#

that is separate and doesn't move with the player

flat crystal
#

do that

prime cove
#

Hmm? How

flat crystal
#

by adding a srprite

#

literally any visible object that is not a child of the player

#

and is close to it

prime cove
#

OK I got it

#

I did it

flat crystal
#

you added it inside the player scene

#

you need to do it in the world scene

prime cove
#

And it's not a child of player

prime cove
flat crystal
#

now try moving around

prime cove
#

No not working

#

And whenever I try to add a visible sprite to the world node/scene it is automatically becoming it's child

#

And by the way it's a 2d top down game.

flat crystal
#

you can see it at the top

#

it shows you have the player scene open

flat crystal
# prime cove

player.tscn is your main scene instead of world.tscn

#

which means that when you run the game, it runs the player scene

prime cove
#

So do I have change it in project settings

prime cove
flat crystal
#

its name is highlighted in blue

#

if you press on world.tscn then there's an option to make it the main scene

prime cove
#

Ok i will do it now will it work

#

I did as you told but no use

flat crystal
#

all you need is a static point of reference that doesn't follow the camera

prime cove
#

U mean stat2d node or a sprite2d node?

flat crystal
#

literally anything that is visible

#

and doesn't follow the camera

prime cove
#

Ok

#

I added a 2d node as root screen to static but not working

flat crystal
#

i give up

prime cove
#

It's working thanks

#

But can I hide that image?

flat crystal
#

you just need something to see that you're actually moving
you can't see movement if there's no point of reference
you just need anything visible other than the player that doesn't move with it how many times do i gotta tell this to you

prime cove
#

Ok i will change the Sprite to mix in with the background then thanks for the help

flat crystal
#

it can be any sprite doesn't have to be that specific one