Torque2D: Is it possible to allow all players to access and use the same movement code in player.cs
by S M · in Torque Developer Network · 10/07/2010 (6:26 pm) · 0 replies
At the moment I have one guy Player1 able to move around the screen using the wasd keys. I was wondering how would you make the file that Player1 uses for movement usable by other players who join the game. At the moment all the functions are specific to Player1.
I got most of the code from the Fish Tutorial.
So it starts off like...
Would something like this even make sense?
and then instead of writing things like
But I don't know how I would actually send in which Player I want to move. Player1 or Player2...
I'm still in the process of setting up the network side of things. But getting this bit figured out will be soooo good.
Any hints/tips are welcomed! :)
p.s. I'm a bit of a beginner when it comes to Torque
I got most of the code from the Fish Tutorial.
So it starts off like...
function Player1::onLevelLoaded(%this, %scenegraph)
{
$Player1 = %this;
moveMap.bindCmd(keyboard, "w", "Player1Up();", "Player1UpStop();");
moveMap.bindCmd(keyboard, "s", "Player1Down();", "Player1DownStop();");
moveMap.bindCmd(keyboard, "a", "Player1Left();", "Player1LeftStop();");
moveMap.bindCmd(keyboard, "d", "Player1Right();", "Player1RightStop();");
}Would something like this even make sense?
function onLevelLoaded(%scenegraph, %player)
and then instead of writing things like
$Player1.setSize( "6 6");shouldn't
%player.setSize( "6 6");work?
But I don't know how I would actually send in which Player I want to move. Player1 or Player2...
I'm still in the process of setting up the network side of things. But getting this bit figured out will be soooo good.
Any hints/tips are welcomed! :)
p.s. I'm a bit of a beginner when it comes to Torque