Forum rules - please read before posting.

Strange control issue with "Player Prefab: First Person"

Hi, I downloaded the Player Prefab: First Person package from here: https://adventurecreator.org/files/AC_FirstPersonPlayer.unitypackage

I've used it in several games earlier with no issues, but after importing it into a new project, I'm noticing that when running the game and while walking around, suddenly the FPS prefab character whirls off it own accord, pointing the player in another direction.

There doesn't seem to be any pattern to this behavior. At a certain interval, the FPS character direction suddenly and abruptly turns by 90 degrees, even if the player is moving the mouse.

I'm using Windows, Unity Editor Version 2022.3.13f1

Is there any code in the latest version of the FirstPersonPlayer Prefab that may be causing a problem?

Comments

  • Wait, I just noticed that AC had an update on Jan 04th. I'm just updating it in my project. Maybe this will fix it. Will post back here if it does (or doesn't)

  • Update: No, it doesn't fix it. After about 20 seconds, the same issue occurs; the FPS player is suddenly and sharply turned around 90 degrees of it own accord, even if the player is moving the mouse.

  • edited January 18

    The FP package itself doesn't override AC's First Person movement system - it should be the same as with AC itself.

    The asset now uses AC's new Template system for installation - did you click "Apply" to have AC install it, or copy over the included prefab manually?

    Are you using Input System or Input Manager for input handling?

    Is this occuring in a fresh project, fresh scene, with no other packages/assets involved? I can't recreate such an issue.

  • edited January 18

    Thanks for your response Chris.

    To confirm this, I created a new project (HDRP) in Unity Editor 2022.3.13f1.
    I then imported into the project the latest version of AC. (1.79.3). I then downloaded the latest First Person Player Prefab from the AC site, doubled clicked it in Explorer and then imported it into my project. I then clicked the "Template_FirstPersonPlayer" and hit Apply.

    Then I put in a simple Plane and put the player start at the center of the plane and hit run.

    And the issue still occurs. About 20 seconds into my just walking around, the game snatches away control of the First Person Character and turns it sharply by some angle. I think the angle grows larger each time it happens.

    Is there any other information I can provide to help you identify why this might be happening?

  • edited January 18

    Update: Some good news: when I build the game into an executable and play it, this issue does not occur. Which means that this is only happening in the Editor.

    Which is a relief, however, it's still an irritant in the editor as we're making an atmospheric horror game and the player suddenly turning makes it hard to play test various scenarios.

    We are developing the game on a beast of a machine - 4070 gfx card with an i9 13900kf processor so there's plenty of juice in-editor. Also, the player turning when playing the game in editor is not due to any framerate glitch/stutter - the automatic turning is smooth, as if the mouse is being flicked to the left/right.

  • oK, on further investigation, I've found out why it's happening, but not the root cause. I turned on the profiler, and just before the point that the fps character suddenly whirls, the profilers shows a massive spike in CPU usage, which appears to be caused by Unity's garbage collector? (Can't seem to embed an image here)

    Never seen this before, but this is my first HDRP project with AC, not sure if this is an HDRP thing.

  • Ok problem solved.

    For anyone who might have this issue, it was due to Unity's Garbage collection causing a massive spike in CPU usage which was causing a brief micro-lag which caused any movement of the mouse to over-compensate.

    The default setting for your project's Garbage Collection should be "Incremental Garbage Collection" (under Project Settings > Player > Configuration.
    (https://docs.unity3d.com/Manual/performance-incremental-garbage-collection.html)

    For some weird reason, this was turned off in my Unity Project even though I never turned it off and even though Unity's latest documentation says that this should be turned ON by default in a new project.

    When I turned Incremental Garbage Collector ON, the spikes disappeared and so did the strange player turning. (Although now there are smaller spikes at more frequent intervals, which I guess is the expected behavior)

  • Thanks for the details - though it sounds like the Garbage Collector is more of a knock-on effect, rather than the source of the problem.

    If you don't mind, could we do a bit more testing to try to find the root cause?

    To do this, turn the option back off, and run the Profiler with Deep Profile enabled. When the spikes appear, pause the game and select one - and view the Hierachy tab underneath. Look for the leaf that's causing the spike (likely the one with the highest GC column), and filter down as far as it goes. Share screenshots and I'll try to see what's going on.

  • Hi Chris, I missed this message, thank you so much for your response, I will do as you say and post my findings and screenshots, thank you!

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.