Calling Show(true) in Reset()

Before the challenge slide, I’d already put Show(true); into RespawningCoin’s Reset() method, so I was surprised to find that the lecture’s approach was so different. I don’t think that I’m missing anything due to networks, but I thought I’d ask just to be safe. (The challenge slide mentions it only needs to be called for non-server players but there’s no logic added to actually address this.)

The challenge version:

Vector3 _previousPosition;

    private void Update()
    {
        if(transform.position != _previousPosition)
        {
            Show(true);
        }
        
        _previousPosition = transform.position;
    }

or

    public void Reset()
    {
        Show(true); // Why not this?
        _alreadyCollected = false;
    }

Hi there,

I think it makes more sense to put in update, this way it will only show the coin once it has reached the new destination. There is no risk of the coin reappearing before it’s been moved to the new location. Generally rendering happens at the end of a frame, so I could foresee some edge cases where the coin blinks back into existence and only moves on the next frame.

However, we are setting the new position right before we call reset anyway, so in this context it should work the same (i.e. it should all happen on the same frame).

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms