Game Development Community

CombatManager not working

by darkwudu · in Torque X 2D · 07/07/2008 (3:33 pm) · 2 replies

I have set up a combat manager in my game, similar to that defined in the Space Warrior tutorial.

- The CombatManager sets up two players to begin the game.
- The players can move about and shoot each other.
- The players die and respawn.

- Upon respawning, the player that died no longer responds to any input!

I can't figure out why this is happening as this is calling the same StartCombat method that works fine at the beginning of the game.

Can anyone think of anything obvious that I might have missed?

#1
07/10/2008 (12:12 am)
You have to step through the code, and see where you might be missing something. Make sure you are assigning the new respawn object as a control object, for the particular player, and that all that fun stuff is happening. I know, for myself, I get tripped up alot by the control object, and assigning input, but once you get the hang of it, it is VERY effective.

Will
#2
07/10/2008 (8:52 am)
This likely has something to do with the ControlObject. The component attached to your player that is responsible for movement shoud setup the control object mapping on register and clear it on unregister. For example...

protected internal override bool _OnRegister(TorqueObject owner)
        {
            if (!base._OnRegister(owner))
                return false;
[b] 
            if (PlayerManager.Instance.GetPlayer(_playerIndex).ControlObject == null)
            {
                PlayerManager.Instance.GetPlayer(_playerIndex).ControlObject = Owner;
                _inputMap = PlayerManager.Instance.GetPlayer(_playerIndex).InputMap;
            }
 [/b] 
            return true;
        }

and...

protected internal override void _OnUnregister()
        {
            base._OnUnregister();

            PlayerManager.Instance.GetPlayer(_playerIndex).ControlObject = null;
        }

The PlayerManager.Instance.GetPlayer(_playerIndex).ControlObject = Owner; line is probably most important since the Owner object is likely to be your player sprite and you probably want it to receive the player input. I get the sense that when your player dies, a line like this is never being called in the respawn. If you do have this line, set a debug break point on it and see if it hits during the respawn.

Like Will says, dealing with inputs is a little tricky but really powerful.

John K.