Don't activate collision penalty on boundaries

This is relating to 16_MM_UBO - tag doesn’t seem to work. Making a Cooldown | GameDev.tv

I was wanting to remove the speed penalty if you hit the wall, as that doesn’t seem like something you should be penalised for. I tried adding tags onto the wall boundaries, but don’t know how to check for the tag on collision before running the cooldown. Any ideas on which conditions I could set to check for a tag on the boundary?

I added a colour change condition to the speed penalty as well, which is easy enough to do by just adding colour changes into the cooldown triggers, and setting the start colour the same way you did the set ‘movement speed’ on start.

Not sure which course this is from.

I went through some of the courses that you could ‘hit the wall’ in and it looks like perhaps it’s the delivery driver from the 2D course.

If that’s the case, you can simply check in the OnCollisionEnter2D before you reduce the speed

void OnCollisionEnter2D(Collision2D other) 
{
    // if it's a wall
    if (other.gameObject.tag == "wall")
    {
        // don't do anything
        return;
    }
    moveSpeed = slowSpeed;    
}

Just saw your edit. Give me a second to go through my project and see what we can do

Thanks for the reply, this is from the visual code course - Making a Cooldown | GameDev.tv - Microbe Mayhem

I’m just not sure how to write that If statement in between the cooldown.

I have some additional nodes in mine, but I have added a ‘tag check’ here and only run the code if the tag does not match ‘walls’


I tried to update the post’s tags but it seems the tag is not there and I can’t add a new tag. The lecture adds the tag automagically, but I can’t.


Edit
I changed the enemies’ graph, but the nodes would be the same on the player. In fact, when I checked my player controller I saw that I already implemented this to only reduce speed if I hit an enemy

image

Not sure if this was somewhere later in the course, or if it was something I did myself

That worked perfectly thank you!
The bit I couldn’t understand was to add the “get game object” from collider. Makes perfect sense once you see it. Thank you for the quick reply.

Good idea adding the Enemy tag to the enemies as well, no that isn’t part of the course :slight_smile: but a really nice add on.

EDIT: Updated the tag to 15_MM_UBO which seems to be the last tag in the series, just to tag this question on that series.

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

Privacy & Terms