Forum rules - please read before posting.

Player does not spawn correctly at Player Starts

Hi, I'm real new to AC, but have ran into an interesting issue. So I followed along with the demo, and created my first scene, and everything was fine. I copied that scene and saved it as scene 2, I went about adding new sprites and everything seemed fine at first, but eventually when I ran the scene the player character would appear in odd places, nowhere near where the player start was. A lot of the time he is floating in the air, with only his feet visible from the top of the screen, sometimes he isnt on the screen at all. And its not like he is always above the player start, hes above and off to the side a little.

Additionally, I noticed that sometimes (only sometimes) when I moved the prefab on screen for the player it will affect where he spawns when the scene is run, although now when I tried to recreate this I cant get it to happen haha. I am making a very low res pixel game, but I dont know if that would have anything to do with it.

I have tried deleting the player start and making new ones, but it just isnt working correctly. Oh, but scene 1 still seems totally fine. I am very confused, and any help would be awesome!

Comments

  • Welcome to the community, @banefire.

    Sounds strange. This is for a 2D game?

    Usually when a sprite-based character appears at the wrong place, it's because their "Sprite child" object is offset from their root parent - ie. the sprite's Transform component doesn't have a position of (0,0,0). Having such an offset will cause them to change position as their root is rotated - though you should get a message in the Console if this is the case.

    Is your Player character object present in the scene file, or is it a prefab spawned into the scene? You can assign your "default" Player prefab into the Settings Manager to have it spawn at runtime automatically - if you're using a local Player object in the scene, that may account for the difference between the two.

    Otherwise, let's see some screenshots of the issue, along with your Player Inspector, Settings Manager, and Scene Manager. You can post them on e.g. imgur.com, and post links here. Do be sure to check the Console as well in case AC's detected an issue automatically.

  • Hi @ChrisIceBox , thanks for the reply!

    First off, yep, it is a 2D game. Second, I went through your suggestions but still couldn't see what I was doing wrong... EXCEPT maybe I am accidentally using 2 prefabs for the new player? I thought when I created the "mynewplayer" like in the demo I just renamed it to "Archer" but it looks like it is associated with the "mynewplayer" one still? Although that is how it is set up on the other scene that works, so I dunno. Either way, here is the link to some screenshots.

    https://imgur.com/a/zOfwZ7U

    Thanks!!

  • A scene's instance of a prefab can have a unique name - it'll still be linked to the prefab. Both can be named independently.

    So "My new Player" is in the scene, Archer is the prefab it's linked to, and "My new Player" is also another prefab assigned in the Settings Manager?

    Since you have a default Player prefab assinged there, what is the effect of disabling all/any Players inside the scene file? Try also unchecking the Turn root object in 3D? Player Inspector field.

    It also looks like your Player character is very small - and you've had to shrink your PlayerStarts to fit. You should instead make your Player bigger by altering the size of his sprite. You can do this by reducing the Pixels Per Unit value in the sprite asset's Inspector.

    Your character should be of a comparable size to the 2D Demo's "Brain" sprites - try placing him beside your Player while you adjust this value to get him the right size. You can then reset your PlayerStarts to unit scale.

    Also, you'll need to adjust your Sprite's Pivot field to Bottom, so that the pivot - and the character's root position - is by his feet. This'll be important when pathfinding. Again, you can use the 2D Demo's Player prefab, Brain2D, to compare.

  • So I wont actually be doing any movement around the screen, where they stand is where they stay, but I will do like, a breathing animation eventually. I tried a lot of what you suggested with no luck.

    I tried to drill deeper to see why it was affecting the main character only, but not any other NPCs,so I randomly tried to remove the Rigidbody 2D component from the main character and that seemed to totally fix the issue!

    Not sure exactly why the Rigidbody was doing that, but for now it looks like my issue is solved. Hopefully it actually is the root cause!

  • Glad to hear it.

    I can't be sure why that would be the case without seeing things for myself, but certainly the character shouldn't need a Rigidbody2D if they aren't going to be moving around.

    In fact, 2D characters in general don't require Rigidbody2D components unless you require 2D collision.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.