This is a 2D game my character is disappearing when I change the movement setting from point and click to drag I don't know why. It disappears after a minute or so of moving around seemingly at random and then comes back and disappears again. I tried changing the culling settings I tried changing the sorting layers none of that seemed to work. Help.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @BigNerd.
What are your AC and Unity versions? Where exactly does your Player go to? You can dock the Scene window beside/under the Game window and select him in the Hierarchy to see.
I get no issue when changing this setting in the 2D Demo - try loading it in on your end and making the same change. Does it occur for you when moving the 2D Demo's Player character, Brain2D, around the 2D Demo scene?
If not, it may be an issue with your Player character. You can confirm this by dropping the 2D Demo's Player prefab into your scene hierarchy (after switching back to your own game's Managers) and running the game. A Player character in the scene file will override your default one, so you can use this trick to see if it's an issue with your Player.
If it is, let's see some screenshots of your Player's full Inspector - as well as any messages being reported by the Console.
Thanks and thanks for responding so quickly! I'm using unity 2019.2.7f2 and the latest version of AC 1.70.4. It's just two way movement on the x axis left and right. It doesn't happen with the Brain asset I'm pretty sure its a problem with my player. I feel like maybe it has something to do with the sorting layers or culling, but I'm unsure. I'm not getting any errors or anything unusual from the inspector either. I'm sort of new to unity so I don't completely know what I'm doing. All the layers are numbers pretty far a part from each other in the sprite renderer, but I have the sorting layer on the objects all set to default is that a problem?
Here's his inspector
https://gyazo.com/2b3b88bab31c7aaae70658657943b3f1
https://gyazo.com/4676a3ebc72f162e9ef8cc478d7fec14
https://gyazo.com/321443458b890cf8362c6fc6df53873c
and here's the child object
https://gyazo.com/9687ebf3358e63e1b473184abeef6860
Yes, if it's OK with Brain then it's likely related to your own Player - though all looks OK from your screenshots.
One thing I do see though is that your character's sprite is pivoting in the centre - this should typically be pivoting at the bottom, so that the character's root object is by their feet. That's likely not related to this issue, however.
Does your animation control the sprite child's position? It's important that the sprite child has a local position of (0,0,0) at all times.
If the character is disappearing, it's likely either that it's going off-screen, or that it's obscured by the background art. It you temporarily hide all background art, is he at least remaining in the correct position on-screen?
One other test to make would be load up the 2D Demo's Managers + Scene, change the Movement method to Drag, and drop in your own Player prefab to override Brain. What is his behaviour then?
All parts of him are at 0,0,0 as far as I can tell so I don't think he's going off screen I'll keep poking around though maybe there's something in here I didn't check.
I removed the background art and he's still disappearing. I can hear his footsteps and move him around still so I think it's just the child object with the graphics and animations on it that's having some kind of issue.
I also tried putting him into the 2d demo and he still disappears.
Keep his sprite child's Inspector open at runtime - does it show anything amiss, e.g. the wrong sprite or a colour with full transparency?
Nothing that I can see... Do you maybe want me to send you the package so you can poke around yourself? You certainly don't have to if you don't want to just offering if that might be easier for you to figure out what's wrong. The point and click works at the very least so it's not a huge huge problem.
If you can create a .unitypackage file of the prefab, their graphics and animation files, as well as your game's Managers - PM it to me and I'll take a look.
I have no problems with dragging the character around in the 2D Demo, but I notice in your Settings Manager that you've got your "Moving and turning" field set to "Screen Space".
Was this intentially set? This mode causes characters to move in 3D space - i.e. along the z-axis, so he'll move behind background sprites if they're not placed far away enough.
Unless you have a specific need to, I recommend leaving this field as its default "Unity 2D" mode, which causes characters to move purely in 2D space (i.e. x and y axes only). You can read more about what these different modes mean in the Manual's "Preparing a 2D scene" chapter.
Oh my gosh I think that was the problem. I switched it and the disappearing stopped... Thank you so much. Of course it was one button I missed.
When I changed it to Unity 2D the hotspots stop working....
The default setting is "Unity 2D" - did you set it to "Screen Space" intentionally?
In "Screen Space", the game is technically in 3D - since the characters move with depth. For this reason, Hotspots must also be in 3D - with 3D colliders, e.g. Box Collider components.
In the standard 2D mode, "Unity 2D", the game is in pure 2D - so Hotspots, NavMeshes etc rely on 2D colliders - e.g. Box Collider 2D, Polygon Collider 2D. AC will also be perfoming 2D Raycasting checks, which aren't able to detect 3D colliders.
I'm afraid that if you want to switch to this mode, you'd have to swap these components - though it may be easier to remove them and replace them. You should find that adding a new Hotspot to the scene works - as it has a 2D collider component attached instead.