Game Development Community

first/third person in beta 5?

by Brent Brzuchalski · in Torque 3D Professional · 08/21/2009 (12:55 am) · 24 replies

has anyone gotten something like this resource http://www.garagegames.com/community/resource/view/9846/ to work with beta 5? all i want to do is the standard arms show in first person and not in third. ive tryed everything i can think of and cant seem to get it to work. thanks in advance!!
Page «Previous 1 2
#1
08/21/2009 (9:40 am)
Just a thought but you might try using the setmeshhidden function in script. Probably best done via a commandtoserver, probably using the default 1st/3rd person key.
#2
08/21/2009 (9:42 am)
thats a good idea...any idea where i could find a sample of that type of thing to look at? thanks
#3
08/21/2009 (11:45 am)
In default.bind try something like this inside togglefirstperson
%player = LocalClientConnection.getControlObject();
if(!isfirstperson == true)
{
   if (%player.getClassName() $= "Player")//quick check it's real
   {
  	%player.setmeshhidden(1, arms);
    }
}
else
{
   if (%player.getClassName() $= "Player")//quick check it's real
   {
  	%player.setmeshhidden(0, arms);
    }
}
No idea if this will actually work.
Brain not working well today ... due to hazy recollection of mead of all things.
Anyhow, you want to get the object you're going to manipulate (the player), the state (1st/3rd) it's in, and then do whatever manipulation is required. Maybe better to make a seperate function and play that function from togglefirstperson, rather than stick it directly in the toggle function
#4
08/21/2009 (12:34 pm)
ok so heres how i added it.....

function toggleFirstPerson(%val)
{
if (%val)
{
ServerConnection.setFirstPerson(!ServerConnection.isFirstPerson());
}
%player = LocalClientConnection.getControlObject();
if(!isfirstperson == true)
{
if (%player.getClassName() $= "Player")//quick check it's real
{
%player.setmeshhidden(1, armtwo2000);
}
}
else
{
if (%player.getClassName() $= "Player")//quick check it's real
{
%player.setmeshhidden(0, arms);
}
}
}

there arent any errors and nothing is broken but it doesnt hide anything either. did i add it in wrong ya think or is it something else ya think?
thanks! :}
#5
08/21/2009 (12:48 pm)
does your model have a mesh called arms?
I have to ask, sometimes we miss the smallest things...
#6
08/21/2009 (12:49 pm)
hmmm, I don't think setmeshhidden works client side, I cannot check the code right now, but that functions should set some flags, and then send them to the client, so if you use it client side, nothing is transmitted and client side those flags aren't set.
#7
08/21/2009 (12:50 pm)
yeah the model has 2 arms armone2000 and armtwo2000
#8
08/21/2009 (1:14 pm)
That wasn't real script, more something to think about.

anyhow, here's some useable script
function toggleFirstPerson(%val)
{
   if (%val)
	{
      ServerConnection.setFirstPerson(!ServerConnection.isFirstPerson());
	}
	%player = LocalClientConnection.getControlObject();
	if(ServerConnection.isFirstPerson())
		{
		%player.setallmesheshidden(0);
		}
	else
		{
		%player.setallmesheshidden(1);
		}
}

This works, just change setallmesheshidden to the other function you want and make sure the mesh names are correct.

My hangover slowly weakens...
#9
08/21/2009 (1:44 pm)
well i must be a total dope cuz i just cant make this work....this is what i put...

function toggleFirstPerson(%val)
{
if (%val)
{
ServerConnection.setFirstPerson(!ServerConnection.isFirstPerson());
}
%player = LocalClientConnection.getControlObject();
if(ServerConnection.isFirstPerson())
{
%player.setmeshhidden(0, arms0);
}
else
{
%player.setmeshhidden(1, arms0);
}
}

i tried various combinations and still nothin....
#10
08/21/2009 (2:03 pm)
Meshnames - Are they correct?

Also:

<input> (0): Player::setMeshHidden - wrong number of arguments.
<input> (0): usage: ( string meshName, bool forceHidden )
Set the force hidden state on the named mesh.

%player.setmeshhidden(yourmesh, 1);
#11
08/21/2009 (2:03 pm)
I haven't tried this.... but after taking a look at the console method I think your parameters may be out of order
ConsoleMethod( ShapeBase, setMeshHidden, void, 4, 4, 
   "( string meshName, bool forceHidden )\n"
   "Set the force hidden state on the named mesh." )
{
   object->setMeshHidden( argv[2], dAtob( argv[3] ) );
}

So maybe it should be
%player.setmeshhidden(arms0, 1);
#12
08/21/2009 (2:09 pm)
yeah its wierd...mesh names are right...and no matter how i put it it wont work and i dont get any errors. sorry to be such a pain to everyone, but thanks a bunch for all the help!
#13
08/21/2009 (2:14 pm)
*cough* change the args around in the script as both me and Mike noticed the faux pas together.
#14
08/21/2009 (2:17 pm)
function toggleFirstPerson(%val)
{
if (%val)
{
ServerConnection.setFirstPerson(!ServerConnection.isFirstPerson());
}
%player = LocalClientConnection.getControlObject();
if(ServerConnection.isFirstPerson())
{
%player.setmeshhidden(arms0,0);
}
else
{
%player.setmeshhidden(arms0, 1);
}
}

like so?
#15
08/21/2009 (5:26 pm)
BTW, if you want to do a quick check to see if an object is real you can use the isObject function.

Instead of:
if (%player.getClassName() $= "Player")

you would do:
if(isObject(%player))
#16
08/21/2009 (5:28 pm)
Also, Steve, your use of boolean operators is somewhat obtuse to say the least ;P

Instead of:
if(!isfirstperson == true)

you could simply check:
if(!%isfirstperson)

edit: Ok, it wasn't as strange as I thought. Regardless, you don't need to use == on bool values. You can simply check if val or !val.
#17
08/21/2009 (6:00 pm)
if(isObject(%player)) doesn't mean that %player is a Player.

I've previously had other objects running - or trying to run - functions which I only wanted the Player to. Hence my security check to make sure it's a Player, and not anything else. though as it's the client control object it's after here, you'd certainly hope it'd return the player and not anything else -- could still be a camera though
#18
08/22/2009 (12:28 am)
i just cant get this to work at all bleh lol
#19
08/22/2009 (9:51 am)
Then you are not calling the correct mesh names.

What you say in post7 and what you say in post14 are different.
#20
08/22/2009 (9:58 am)
yeah i changed the name to arms0 and reexported just to make sure it wasnt somethin with the model
Page «Previous 1 2