- Home /
Question by
Besi2019 · Feb 23, 2018 at 11:43 PM ·
flickeringcheckpoint
Checkpoint flickering
Hi there
When the player hits the checkpoint, then falls, then comes back to the checkpoint, the player is flickering.
Is it my checkpoint or the player, which is the issue?
my checkpoint script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CheckpointController : MonoBehaviour {
public Sprite flagClosed;
public Sprite flagOpen;
private SpriteRenderer theSpriteRenderer;
public bool checkpointActive;
// Use this for initialization
void Start () {
theSpriteRenderer = GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
theSpriteRenderer.sprite = flagOpen;
checkpointActive = true;
}
}
}
Comment
Answer by Besi2019 · Feb 25, 2018 at 06:03 PM
I found the issue, but I cant seem to fix it.
It has to do with my z position. The player has a Z position on 2, and the checkpoint a Z position on 1. When the player hits the checkpoint, it has a new position, and thats called 1. So its starts flickering, because it has the same Z position as the checkpoint. but why, does it change its Z position??
Any help?
Your answer
![](https://koobas.hobune.stream/wayback/20220612153306im_/https://answers.unity.com/themes/thub/images/avi.jpg)