Search Results for 'fader'
-
Search Results
-
Anonymes FRACTAL has helped us point out a few bugs on the project files for Part 7 of this series:
This is better, I can now move my player, but always bugs. Respawn button is broken and i have 3 error in console :
NullReferenceException: Object reference not set to an instance of an object SceneFader.SetColorImage (System.Single& _alpha, SceneFader+FadeDirection _fadeDirection) (at Assets/Scripts/SceneFader.cs:71) SceneFader+d__5.MoveNext () (at Assets/Scripts/SceneFader.cs:40) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) SceneTransition:Start() (at Assets/Scripts/SceneTransition.cs:26)
There can be only one active Event System. UnityEngine.EventSystems.EventSystem:OnEnable () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:424)
EndOfStreamException: Unable to read beyond the end of the stream. System.IO.BinaryReader.ReadByte () (at :0) System.IO.BinaryReader.Read7BitEncodedInt () (at :0) System.IO.BinaryReader.ReadString () (at :0) SaveData.LoadBench () (at Assets/Scripts/Singletons/SaveData.cs:71) GameManager.RespawnPlayer () (at Assets/Scripts/Singletons/GameManager.cs:64) UnityEngine.Events.InvokableCall.Invoke () (at :0) UnityEngine.Events.UnityEvent.Invoke () (at :0) UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272) UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
Topic: [Part 5] remarks on errors
Hey, I’m here again.
Changing the Enemy script to use Start() instead of Awake() isn’t mentioned on the blog post (after section 2.c).
Section 2.d on the video tells to change “this” to “gameObject”, but previous code already had that. Health = maxHealth; is moved from Awake() to Start(), but that isn’t shown on the code (it was just removed), and while it’s shown on the video, it’s very fast and not mentioned.
The 2D DarkCave Assets pack is said to be in the description of the video, but it isn’t. Though it is on the blog post.
On Section 3, I noticed that my camera settings weren’t the same as shown in the video, values for Position, Projection, and MSAA were different (I think I followed the tutorial pretty closely, so it was either not mentioned or too fast for me to notice the changes). Also, the Offset value on my script was -20 and the Inspector on the video shows -15.
I don’t think it was mentioned to remove the previous “Floor” objects from testing.
About wall placement, video and blog say -1, but a card on the video says 1.
When adding the fog, I can only see the column if the alpha value is under 20, somehow. At the beginning of the video it’s said to make the player a prefab, what about the enemy?
When adding vegetation, the blog says to use the Multiple mode (and shows a Single image), while the videos doesn’t tell to change that. I tried Multiple and with that you can’t drag and drop the image on the scene, so I assume it was just a copy and paste gone wrong there.
At 29:22 it’s said to go to Edit > Build Settings, but for me it is File > Build Settings.
In the blog post, the part about the transition manager doesn’t have a semicolon on “SceneManager.LoadScene(transitionTo)”.
The public IEnumerator WalkIntoNewScene() has a “<” out of place around line 281 on the Player Controller (blog post). On the blog it shows the line “if (_exitDir.y != 0)” while the video shows “if (_exitDir.y > 0)”.
The code for PlayerStateList adding “cutscene” isn’t on the blog. Adding “if (pState.cutscene) return;” in Update() and FixedUpdate() isn’t shown as well.
I think “PlayerController.Instance.pState.cutscene = true;” on the SceneTransition trigger wasn’t mentioned (isn’t on the blog).
At 34:11 the Exit Time was changed offscreen from 0.25 to 0.5.
The use of Prefabs for the Scene Transition seems to cause me bugs. Even though I changed the name of the destination, it still uses the value of the prefab instead, e.g. I’d make a prefab of the cave_2 transition, use it on cave_2 and assign it to cave_2, and every time I’d exit cave_2, I’d enter it. At some point I even went to cave_3 when I removed the scene name from the prefab (even though it was still assigned after dragging the prefab to the hierarchy).
At 35:51 there are multiple steps that aren’t mentioned, and even with the blog description I’m not sure I got it after even watching at 0,25x speed. A script was added, the scene fader was dragged to the prefab… in 10 seconds there are at least 7 steps. The part at 36:11 was clearly an edit problem, it shows a previous state of the Scene Fader object, when it didn’t have a script and was still white and not stretched.
using UnityEngine.UI; isn’t shown on the code for SceneFader.cs on the blog. fadeOutUIImage has line break where the serialize field should’ve been removed. The code for FadeDirection was skipped and isn’t shown on later codes. [SerializeField] private float fadeTime; isn’t declared. On UIManager.cs, only sceneFader = GetComponentInChildren<SceneFader>(); is declared, without variable or Start() function shown on the blog. The first code block of SceneFader names the class as “UIManager” instead of SceneFader.
Trying to copy the drag and drop to supposedly update the Prefab I ended up fucking everything up and basically replacing the HP and mana with the scene fader… which made the player prefab lose the reference to mana and I can’t seem to update it correctly.
When fixing the flashing effect, the variable canFlash isn’t in the code.
After fixing the flashing effect the player object is shown as lower quality and the camera is zoomed in for whatever reason. It’s like it went to 140p video quality. (restarting the editor fixed it).
For whatever reason, the heart containerts won’t appear filled up anymore, without me changing anything.
Starting on part 6 I’ll probably just ask questions if I can’t solve the problems I find.
there is an error that happens when my player touches the scene transition in makes the player not enter the next scene the error points out the NullReferenceException: Object reference not set to an instance of an object SceneTransition.OnTriggerEnter2D (UnityEngine.Collider2D _other) (at Assets/scripts/SceneTransition.cs:37)
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class SceneTransition : MonoBehaviour { [SerializeField] private string transitionTo; [SerializeField] private Transform startPoint; [SerializeField] private Vector2 exitDirection; [SerializeField] private float exitTime; private void Start() { if(transitionTo == GameManager.instance.transitionFromScene) { PlayerController.instance.transform.position = startPoint.position; StartCoroutine(PlayerController.instance.WalkIntoNewScnene(exitDirection, exitTime)); } StartCoroutine(UiManager.instance.sceneFader.fade(ScreenFader.fadeDirection.Out)); } private void OnTriggerEnter2D(Collider2D _other) { if (_other.CompareTag("Player")) { GameManager.instance.transitionFromScene = SceneManager.GetActiveScene().name; PlayerController.instance.pState.transition = true; StartCoroutine(UiManager.instance.sceneFader.FadeAndLoadScene(ScreenFader.fadeDirection.In, transitionTo)); } } }
Topic: [part 6] spikes freeze game
not sure why – no compiler or any errors occuring – when i touchs spikes, my game will freeze. ive set debug logs in every stage of the IEnumerator and it seens to not work when the scene fader occurs (it works during scene transitions) ive set a respawner in my game and all script stuff is proper
reference for my spike script – debug log will print – 1, 2, 3, 4, respawn, takes damage
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spikes : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } private void OnTriggerEnter2D(Collider2D _other) { if (_other.CompareTag("Player")) { StartCoroutine(RespawnPoint()); Debug.Log("respawn"); } } IEnumerator RespawnPoint() { PlayerController.Instance.pState.cutscene = true; Debug.Log("1"); PlayerController.Instance.pState.invincible = true; Debug.Log("2"); PlayerController.Instance.rb.velocity = Vector2.zero; Debug.Log("3"); Time.timeScale = 0; StartCoroutine(UIManager.Instance.sceneFader.Fade(SceneFader.FadeDirection.In)); Debug.Log("4"); PlayerController.Instance.TakeDamage(1); Debug.Log("Takes damage"); yield return new WaitForSeconds(1); Debug.Log("5"); PlayerController.Instance.transform.position = GameManager.Instance.platformingRespawnPoint; Debug.Log("6"); StartCoroutine(UIManager.Instance.sceneFader.Fade(SceneFader.FadeDirection.Out)); Debug.Log("7"); yield return new WaitForSeconds(UIManager.Instance.sceneFader.fadeTime); Debug.Log("8"); PlayerController.Instance.pState.cutscene = false; PlayerController.Instance.pState.invincible = false; Debug.Log("9"); Time.timeScale = 1; } }
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class SceneFader : MonoBehaviour { [SerializeField] public float fadeTime; private Image fadeOutUIImage; public enum FadeDirection { In, Out } private void Awake() { fadeOutUIImage = GetComponent<Image>(); } public IEnumerator Fade(FadeDirection _fadeDirection) { float _alpha = _fadeDirection == FadeDirection.Out ? 1 : 0; float _fadeEndValue = _fadeDirection == FadeDirection.Out ? 0 : 1; if (_fadeDirection == FadeDirection.Out) { while (_alpha >= _fadeEndValue) { SetColorImage(ref _alpha, _fadeDirection); yield return null; } fadeOutUIImage.enabled = false; } else { fadeOutUIImage.enabled = true; while (_alpha <= _fadeEndValue) { SetColorImage(ref _alpha, _fadeDirection); yield return null; } } } public IEnumerator FadeAndLoadScene(FadeDirection _fadeDirection, string _sceneToLoad) { fadeOutUIImage.enabled = true; yield return Fade(_fadeDirection); SceneManager.LoadScene(_sceneToLoad); } void SetColorImage(ref float _alpha, FadeDirection _fadeDirection) { fadeOutUIImage.color = new Color(fadeOutUIImage.color.r, fadeOutUIImage.color.g, fadeOutUIImage.color.b, _alpha); _alpha += Time.deltaTime * (1 / fadeTime) * (_fadeDirection == FadeDirection.Out ? -1 : 1); } }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class SceneTransition : MonoBehaviour { [SerializeField] private string transitionTo; //Represents the scene to transition to [SerializeField] private Transform startPoint; //Defines the player's entry point in the scene [SerializeField] private Vector2 exitDirection; //Specifies the direction for the player's exit [SerializeField] private float exitTime; //Determines the time it takes for the player to exit the scene transition // Start is called before the first frame update private void Start() { if (GameManager.Instance.transitionedFromScene == transitionTo) { PlayerController.Instance.transform.position = startPoint.position; StartCoroutine(PlayerController.Instance.WalkIntoNewScene(exitDirection, exitTime)); } StartCoroutine(UIManager.Instance.sceneFader.Fade(SceneFader.FadeDirection.Out)); } private void OnTriggerEnter2D(Collider2D _other) { if (_other.CompareTag("Player")) { GameManager.Instance.transitionedFromScene = SceneManager.GetActiveScene().name; SceneManager.LoadScene(transitionTo); PlayerController.Instance.pState.cutscene = true; StartCoroutine(UIManager.Instance.sceneFader.FadeAndLoadScene(SceneFader.FadeDirection.In, transitionTo)); } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameManager : MonoBehaviour { public string transitionedFromScene; public Vector2 platformingRespawnPoint; public static GameManager Instance { get; private set; } private void Awake() { if(Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } DontDestroyOnLoad(gameObject); } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlatformRespawnPoint : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } private void OnTriggerEnter2D(Collider2D _other) { if (_other.CompareTag("Player")) { GameManager.Instance.platformingRespawnPoint = transform.position; } } }