Forum begins after the advertisement:


Part: 10 Scene Transition

Home Forums Video Game Tutorial Series Creating a Farming RPG in Unity Part: 10 Scene Transition

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #17306
    Jhan Khendrick Perez
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    I am having an issue in which the ParentedAnimationEvent is returning this error

    SendMessage OnFadeInComplete has no receiver! UnityEngine.Component:SendMessageUpwards (string)

    and it stops the game

    View post on imgur.com
    #17307
    Jhan Khendrick Perez
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    I see now, my Player Canvas was not child on the GameManager in which the UIManager is located

    #17308
    Jhan Khendrick Perez
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    Asking for assistance, I am using the Fade Transition approach based on the guide on my Teleport Script (not changing the scene) it only changes the position of the player when the screen is now all black. My issue is that I don’t know the correct logic or proper arrangement since when I teleport the screen goes complete black and not fading to black. I am using the same approach on changing the scene, but instead it only changes the player position

    View post on imgur.com
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Cinemachine;
    
    public class Teleport : MonoBehaviour
    {
        [Header("Teleport Settings")]
    
        // The destination Transform to teleport to
        public Transform teleportDestination;
        public GameObject guideUI;
        public CinemachineVirtualCamera targetCamera;
    
        // The tag to identify the player
        public string playerTag = "Player";
    
        private GameObject playerInTrigger;
    
        private void Start()
        {
            if(guideUI != null)
            {
                guideUI.SetActive(false);
            }
        }
    
        void OnTriggerEnter(Collider other)
        {
            // Check if the object entering the trigger is the player
            if (other.CompareTag(playerTag))
            {
                playerInTrigger = other.gameObject;
                PlayerMove.isInTeleportTrigger = true; //Prevent interaction
                if (guideUI != null)
                {
                    guideUI.SetActive(true);
                }
            }
        }
    
        void OnTriggerExit(Collider other)
        {
            // Clear the reference when the player leaves the trigger
            if (other.CompareTag(playerTag))
            {
                playerInTrigger = null;
                PlayerMove.isInTeleportTrigger = false; //Allow interaction again
                if (guideUI != null)
                {
                    guideUI.SetActive(false);
                }
            }
        }
    
        void Update()
        {
            if (guideUI != null)
            {
                guideUI.SetActive(playerInTrigger);
    
                if (targetCamera != null)
                {
                    Vector3 direction = guideUI.transform.position - targetCamera.transform.position;
                    guideUI.transform.rotation = Quaternion.LookRotation(direction, Vector3.up);
                }
            }
    
            // Check if the player is in the trigger and the F key is pressed
            if (playerInTrigger != null && Input.GetKeyDown(InputManager.Instance.interactKey))
            {
                StartCoroutine(TeleportWithFade());
            }
        }
    
        private IEnumerator TeleportWithFade()
        {
            PlayerMove.isUIOpen = true;
    
            // Trigger fade-out
            NewUIManager.Instance.FadeOutScreen();
    
            // Wait for 1 second (adjust if needed)
            yield return new WaitForSeconds(1f);
    
            // Teleport player
            playerInTrigger.transform.position = teleportDestination.position;
            playerInTrigger.transform.rotation = teleportDestination.rotation;
            Debug.Log("Player teleported to " + teleportDestination);
    
            // Trigger fade-in
            NewUIManager.Instance.FadeInScreen();
    
            // Wait for fade-in to complete
            yield return new WaitForSeconds(1f);
    
            // Reset fade effect
            NewUIManager.Instance.OnFadeInComplete();
            NewUIManager.Instance.ResetFadeDefaults();
    
            PlayerMove.isUIOpen = false;
        }
    }
    public static NewUIManager Instance { get; private set; }
    
    [Header("In-Game Time")]
    public TextMeshProUGUI dateText;
    public TextMeshProUGUI timeText;
    
    [Header("Player Equipped Slot")]
    public Image toolEquippedIcon;
    public TextMeshProUGUI toolQuantityText;
    
    public Image harvestEquippedIcon;
    public TextMeshProUGUI harvestQuantityText;
    
    [Header("Storage")]
    public NewHandInventorySlot storageEquippedSlot;
    public NewInventorySlot[] storageSlots;
    
    [Header("Harvest")]
    public NewHandInventorySlot harvestEquippedSlot;
    public NewInventorySlot[] harvestSlot;
    
    [Header("Info Box")]
    public GameObject itemInfoBox;
    public TextMeshProUGUI itemNameText;
    public TextMeshProUGUI itemDescriptionText;
    
    [Header("Yes No Prompt")]
    public YesNoPrompt yesNoPrompt;
    
    [Header("Player Stats")]
    public TextMeshProUGUI moneyText;
    
    [Header("Shop")]
    public ShopListingManager shopListingManager;
    
    [Header("Stamina")]
    public Slider energyBar;
    public int staminaCount;
    
    [Header("Hunger Bar")]
    public Slider hungerBar;
    public int hungerCount;
    
    [Header("Screen Transitions")]
    public GameObject fadeIn;
    public GameObject fadeOut;
    
    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this);
        }
        else
        {
            Instance = this;
        }
    }
    
    private void Start()
    {
        PlayerStats.RestoreStamina(100);
        RenderInventory();
        AssignSlotIndexes();
        RenderPlayerStats();
        DisplayItemInfo(null);
    
        TimeManager.Instance.RegisterTracker(this);
    }
    
    public void FadeOutScreen()
    {
        fadeOut.SetActive(true);
    }
    
    public void FadeInScreen()
    {
        fadeIn.SetActive(true);
    }
    
    public void OnFadeInComplete()
    {
        fadeIn.SetActive(false);
    }
    
    public void ResetFadeDefaults()
    {
        fadeOut.SetActive(false);
        fadeIn.SetActive(true);
    }
    #17311
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::
    I see now, my Player Canvas was not child on the GameManager in which the UIManager is located
    Did you manage to fix the ParentedAnimationEvent issue?
    #17312
    Jhan Khendrick Perez
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    Yes, the only problem now is the instant FadeOut when teleporting

    #17313
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    I’m not very familiar with the farming RPG project, but is there an animation that does the fade out? Do double check and see if you are setting up the animation correctly.

    I’ll ask Jonathan (the series author) to have a look for you as well.

    #17315
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    @jhankhendrickperez I’ve checked with Jonathan. He says that you need to have a look at your animation as well. It’s likely that its misconfigured, or you forgot to put it in.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: