Game Development Community

Disabling Movement and Shooting while dead

by Steven Sheffey · in TGB Platformer Kit · 09/12/2008 (12:45 am) · 3 replies

Hey everyone. Im looking for a way to stop the user from having any control as far as movement and shooting is concerned when they die and respawn. Im using the ShootBehavior along with the three default behaviors used to control the dragon. Iv'e looked over the Asteroids Tutorial and found that the issue was fixed by using the %this.Owner.Control == 0;. Unfortunately it seems this is not workingfor me. Perhaps I'm using the code in the wrong place. Ive added this code into the ShootsBehavior and Im pretty sure as far as movement Im supposed to add this code into the ActorBehavior or ControllerBehavior.

If there is an easier way to do this? Should I be using the State changes instead? Overall everything I try is having no affect and Im still able to shoot and move during the respawn and die areas.

If anyone else has or has had a similar problem, hit me up and we can help each other! Thanks.

#1
09/12/2008 (1:06 am)
Steven, the ShootBehavior wasn't strictly designed for the PSK, however, you can create one so that it does work nicely!

What I suggest you do is duplicate the ShootBehavior and call it "ActorShootBehavior". Then, inside the shoot function, do a quick check to make sure that the actor is not dead before shooting.

The new function would look something like this:

function ActorShootsBehavior::fire(%this, %val)
{
   if (!%this.Owner.ActorBehavior.Alive)
      return;
   
   ...
}

I've not tested it, but I hope it helps!
#2
09/12/2008 (4:52 am)
Oh jeez Phillip sorry bout that =) Noobie mistake on my part. I was missing the .ActorBehavior part. Haha duh. I applied this logic within the ControllerBehavior as well. It works like a charm, thanks a bunch!
#3
09/12/2008 (2:27 pm)
You are most welcome!