Forum rules - please read before posting.

Player Start On Load Issue

There is something funny that happens when a previous game is loaded. The moment the game is loaded, the player will run off the screen. He just runs through the wall and is gone. You can click the floor and he will be back. Is this due to player starts? What is the best way to tackle this if there is no player start for load?

Comments

  • edited November 2022

    Hi Jamesfootlight,

    I had the same issue and solved it with a script.

    Create a OnLoadStopWalk.cs file with the following content (Unity 2020.3.14f1):

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class OnLoadStopWalk : MonoBehaviour
    {
        List<AC.PlayerPrefab> players;
    
        // Start is called before the first frame update
        void Start()
        {
            AC.EventManager.OnFinishLoading += StopWalking;
            AC.EventManager.OnAfterChangeScene += StopWalking;
        }
    
        private void StopWalking()
        {
    
            players = AC.KickStarter.settingsManager.players;
    
            foreach (AC.PlayerPrefab currentplayerPrefab in players)
            {
                AC.Player currentplayer = currentplayerPrefab.GetSceneInstance();
                if (currentplayer)
                {
                    currentplayer.Halt();
    
                }
            }
    
            AC.KickStarter.player.Halt();
        }
    
        private void StopWalking(AC.LoadingGame loadingGame)
        {
    
            StopWalking();
        }
    
        // Update is called once per frame
        void Update()
        {
    
        }
    }
    

    Then add is as a script to your persistent engine. You can find it in the Folder: AdventureCreator/Ressources/

    This will stop your player from walking after load.

    Best
    Kai

  • Awesome 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.