Controlling two characters at once
by James Slade · in Torque X 2D · 04/04/2010 (9:29 am) · 9 replies
I'd like to be able to control two player characters at the same time, each controlled by an analogue stick. I've been playing with the MovementComponent.CS from the Guidebook but can't figure out how to assign the right stick to a animated sprite in the same way that the left one is already controlled.
From the guide I can have the right-stick controlled player move around but I can't assign direction-specific animations to it. Any help appreciated.
#2
e.g if I push the right stick to the left, it seems to animate the object controlled by the left stick and sets off the walk left animation. I"d like to be able to control to characters independently, assigning different animations to each of the 8 ways the object can move.
04/04/2010 (12:13 pm)
Thanks, I already figured that part out and the right stick controlled sprite does move, but when I try to assign animations to these movements the right stick seems to control animations for the left stick character e.g if I push the right stick to the left, it seems to animate the object controlled by the left stick and sets off the walk left animation. I"d like to be able to control to characters independently, assigning different animations to each of the 8 ways the object can move.
#3
04/04/2010 (4:57 pm)
they would each need a different component or some flag to tell them if its the right stick or left stick. Basically you would make a right stick component that is the same as the left stick component but use Sticks[1] instead of Sticks[0]
#4
unless you add a reference to the other sprite into the movement component and change the animations through that. (but it would be alot simpler to use 2 components)
04/04/2010 (6:30 pm)
Basicly the easiest way to do this is to use 2 components as Henry said unless you add a reference to the other sprite into the movement component and change the animations through that. (but it would be alot simpler to use 2 components)
#5
04/05/2010 (12:29 am)
Thanks for the help so far. I have created a second movement component for the right hand character. However, this component only works when I exclude the first movement component from the project. When both are included only the left hand stick character moves.
#6
04/05/2010 (2:13 am)
On the right hand component leave out the stick bindings. Only put in the animations on move.
#7
04/05/2010 (3:09 am)
Not sure I follow, do you mean remove the input map from the right hand component?
#8
04/05/2010 (11:11 am)
Is there a way to retrieve the Move object globally instead of relying on the Move object passed into ProcessTick? That would make this very simple.
#9
Meanwhile here is Matt's code on reading a stick: www.torquepowered.com/community/forums/viewthread/100513/1#comment-670927
Maybe that will help?
04/05/2010 (5:22 pm)
OK I was totally wrong, this will take some more investigation. You cannot have a move in the process tick on two different components? This is intrigueing.Meanwhile here is Matt's code on reading a stick: www.torquepowered.com/community/forums/viewthread/100513/1#comment-670927
Maybe that will help?
Torque 3D Owner Henry Shilling
Smokin Skull
to read the sticks in your process tick you use move.Sticks[0] for the left stick and move.Sticks[1] for the right.
I use this for a dual stick shooter and it works great