Be the first to post for 'Calling Methods Via Interfaces'!

If you’re reading this, there probably aren’t very many posts yet. But don’t worry, you can be the first! Either create a new post or just reply to this one to say ‘hi’.

The lecture presents a very roundabout path to getting an IDamageable. I think the power of interfaces gets lost.

    void OnTriggerEnter(Collider other) {
        IDamagable damageable = other.GetComponent<IDamagable>();
        if (damageable != null) damageable.TakeDamage(damageDone);
    }
1 Like

Thanks for the honest feedback.

I think the power of interfaces will become clearer later in the section as we use them more.

1 Like

Seems that the HP bars of the enemies are reversed compared to that of the player. In my project as well is in course video.

@ben
An easy fix is to rotate the UI Slot, I guess. Can you explain why this rotation is needed? Or will it be discussed later?:slight_smile:

Seems that when game is started and the rotation of a enemy is above 180 degrees, the HP bar shows reversed(seen when taking damage). The HP bar is also a lot bigger when enemy starts with a 0 rotation. then when a small rotation is applied.

What I have seen is that during game start, any rotation on the enemy will cause an offset on the HP bar graphic. During runtime this doesn’t change. Looks like just rotating the UI slot is not the solution. :slight_smile:

Looks like this implementation has multiple challenges…

Was just about to comment a similar thing :slight_smile:

Since we know it’s an interface we don’t really need to go the way around and make it a component and then use it as an IDamageable.

1 Like

Why can’t we use the brackets to get the component? It’s definutely allowed by C#; were you implying it was just bad practice? I’ve always used that method and just checked if it’s null or not, whether I’m getting an interface or not. The profiler records it as having a very small footprint.

Privacy & Terms