Game Development Community

Problem between armTread pose and crawl pose

by CIMO · in Torque Game Engine · 09/20/2006 (12:52 am) · 16 replies

I use a adding new pose resource...
And use a armThread in my player for different type of weapon...And a see a problem..
If my player stay in crawl position and have a weapon (with armThread positon) the my "crawl pose" result strange!! innatural...
I thought to put this in weapon.cs
if (%this.armthread $= "")
   	%obj.setArmThread(root);
   else
   	%obj.setArmThread(%this.armThread);
//this
if (%obj.setPlayerPosition(3))
   %obj.setArmThread();
//this
But not function....
I would remove armThread in my payer when stay in a crawl pose...
and return armThread when my player out the crawl pose....
Thanks =)

#1
09/21/2006 (9:16 am)
Any help me? i right code for my idea? help please....thanks for all
#2
09/21/2006 (9:31 am)
I'm not using the crawl resource and I doubt this will work however to me this would make more sense:
if (%obj.setPlayerPosition == 3)
#3
09/21/2006 (9:44 am)
Oh i TIM =D =D
Never ... not function....
in default.bind.cs i use this for this resource:
function doCrawl(%val)
{
   if (%val)
      // calling it with a 0 will bump us up to the next position
      CommandtoServer('SetPlayerPos', 3);
}
moveMap.bind(keyboard, ".", doCrawl);

in command.cs i put this:
function serverCmdSetPlayerPos(%client,%pos)
{
   if (isObject(%client.player))
      %client.player.setPlayerPosition(%pos);
}
function serverCmdGetPlayerPos(%client)
{
   if (isObject(%client.player))
      return %client.player.getPosition();
   else
      return 0;
}

and in weapon.cs i put this
if (%this.armthread $= "")
   	%obj.setArmThread(root);
   else
   	%obj.setArmThread(%this.armThread);

if (%obj.setPlayerPosition == 3)
	%obj.setArmThread();
#4
09/21/2006 (9:53 am)
I wouldn't think weapon.cs is the best place to put it as that function is only called on mounting of an image.

Try doing it in the SetPlayerPos function.

Oh, and it seems you have a function to get the player position so I suggest using that.
#5
09/21/2006 (10:07 am)
Never....
Not function....
WHY? i put in command.cs but not function...
I woul the my player stay in a crawl pose and delet a armThread....
If my player stay in stand pose and have a normal armThread...when stay in a crawl pose the armthread delet....
#6
09/21/2006 (10:18 am)
Cimo, you want to do something more like this.

if(%obj.getPlayerPosition() == 3)
      %obj.setArmThread()

That is, of course, assuming that %obj is actually the player object and not something else entirely. In the first part of you're code you're using %this, then change for some reason to %obj.


I know I've said it several times, but don't get in such a rush to implement something. Take your time, it will help reduce the amount of errors you run into. Every time you rush to implement a resource you make mistakes, which get you flustered, which then makes it harder to solve your problem
#7
09/21/2006 (10:23 am)
No no...this is a my idea....
not in resource.....The resource function perfectly....
But when my player stay in a crawl pose...and i have a weapon with armThread...a crawl pose function...but the arm stay in a "arnThread pose" weapon....
I try to stay in a crawl pose never weaon and a crawl pose function and see very well....
I have thought to delete the armThread weapon pose when my player stay in a crawl pose...
This ... and i try all...but never....
Not say the problem....
#8
09/21/2006 (10:36 am)
%obj.setArmThread(crawlPose)

Be sure to make the appropriate thread in your player model.

Listen to what Scott said, he was nice enough to provide code on how to determine when the player is crouching.

P.s. we know what you're trying to achieve :P
#9
09/21/2006 (10:45 am)
Why don't you:

Use echo's to determine which sections of your code are working?

Buy one of the many books available on Torque scripting?

Learn from the code that others provide rather than copy / pasting then forgetting about it if it worked?

Stop making your game in order to take time off and learn the basics of Torque and the fundamentals of its scripting language?

Anyhow, good luck.
#10
09/21/2006 (10:48 am)
I have a book all game in one...
But i learn with a person...i'm italin boy and my english is not perfect.... =P
I use this forum for support and learn......
I try and try all but
Never....I put in weapon....and never...
I put in command in functio set and get...and never...
Uff i'm stay crasy for this......Sorry but the problem is my head...

I say not all for torque but this community stay here for this....

This problem is very crazy for my head...
sorry
#11
09/21/2006 (11:06 am)
Wow, that post was crazy for my head.
#12
09/21/2006 (11:20 am)
? sorry? for my english? =P sorry but i not say resolve this problem...
uff i would resolve but i try all but never =(
#13
09/21/2006 (12:08 pm)
I use this in default.bind.cs
function doCrawl(%val)
{
   if (%val)
   {
      // calling it with a 0 will bump us up to the next position
      CommandtoServer('SetPlayerPos', 3);
	$posizione = "sdraiato";
   }
}
moveMap.bind(keyboard, ".", doCrawl);

function doStand(%val)
{
   if (%val)
      // calling it with a 0 will bump us up to the next position
      CommandtoServer('SetPlayerPos', 1);
}
moveMap.bind(keyboard, "m", doStand);

and this in command.cs
function serverCmdSetPlayerPos(%client,%pos)
{
   if (isObject(%client.player))
      %client.player.setPlayerPosition(%pos);
   if ($posizione $= "sdraiato")
	%client.player.setArmThread(crawlroot);
}

This function....But if i return to stand pose whit "m key" the player return but with armThread....
A mode for delet the armThread call in function serverCmdSetPlayerPos?
thanks .... help please....
#14
09/21/2006 (12:40 pm)
There are a few reasons it's not working. For one, you're only checking against one position for setting the arm thread. If you set the arm thread and then change positions it will still be what you set it to unless check for it and change it back.

The globals are also highly redundant and will lead to problems in networking. Use the method I showed you earlier.

In this case it should look more like this:

function serverCmdSetPlayerPos(%client,%pos)
{
     if (isObject(%client.player))
         %client.player.setPlayerPosition(%pos);   
     
     //check for going to crawling, set the ArmThread to the crawl animation
     if (%client.player.getPlayerPosition() == [b]Number for the crawl position[/b])
          %client.player.setArmThread([b]Name of Crawl Animation[/b]);

     //check for going to standing, set the ArmThread to the standing animation
     if(%client.player.getPlayerPosition() == [b]Number for the standing position[/b])
           %client.player.setArmThread([b]AnimationName[/b]);
}

The bolded text are placeholders. My way of giving you example code but forcing you to study and understand it.

Now, like Tim said, please don't simply copy and paste this and never think about it again. Study it, understand why it works, and learn from it. I also highly recommend that you pick up a book on C++ programming, preferably one written in your native tongue as that would help the language barrier. That will help you understand the basics of programming and will in turn help you with both Torque's scripting and source code.
#15
09/21/2006 (12:50 pm)
I try this....but there is a problem.....
I have a my weapon "g36C" whit armThread ... "lookG36C"
I use this script but if i stai in a crawl pose the modify function...
if(%client.player.getPlayerPosition() == 1)
%client.player.setArmThread(AnimationName);
But if i return in a stand pose remaing in a "animationName"....
This is a problem...
I woul stay in a crawl pose and function...
but when i return in a stend pose.... i return whit a pose of my weapon....
this is the problem....
#16
09/22/2006 (6:43 am)
It's posible to saty in a crawl pose when i press the my key and delet a armThread only stay in a crawl pose?
If stay in 1 or 2 pose all ok...
But i woul that my player stay ONLY in a crawl pose also if i change the my weapon ( whit armThread )
It's possible? thanks