This site requires JavaScript, please enable it in your browser!
Greenfoot back
I3litz
I3litz wrote ...

2024/1/24

Platform that one shot my character!!!

I3litz I3litz

2024/1/24

#
Im programming a game wich has a platform that should deals 1 damage. But if he touch it all of his health goes away. Can someone please help me!
Kyuubi Kyuubi

2024/1/24

#
provide code?
I3litz I3litz

2024/1/24

#
public void lavaBlock()
    {
        Ritter r = new Ritter();
        if(isTouching(Ritter.class))
        {
            r.leben = r.leben -1;
        }
    }
its on german, i need some sort of an cooldown.
Kyuubi Kyuubi

2024/1/24

#
it might be caused by the fact that it is loosing HP as long as it is touching it, do you have a part that lets say, moves the character out of the damage zone after taking one damage, or you could use a variable to only damage him once.
I3litz I3litz

2024/1/24

#
Thats why i need help, i dont know how to do that. I need like an timer or something else. If it touch 1 HP 5 seconds immunity
Kyuubi Kyuubi

2024/1/24

#
try this
public void lavaBlock()
    {
        private int Immunity=120;
        Ritter r = new Ritter();
        if(isTouching(Ritter.class)&&Immunity<=0)
        {
            r.leben = r.leben -1;
            Immunity=120;
        }else{Immunity--;}
    }
assuming there are 60 acts a second, you might need to change the immunity timer by liking. If you have a code for a health bar I would recommend including it there
I3litz I3litz

2024/1/24

#
Thank you so much, it worked. I've been stuck since a week. You made my day :)
Kyuubi Kyuubi

2024/1/24

#
Ur welcome dwdw :)
You need to login to post a reply.