Game Development Community

Changing location and rotation of one player relative to another

by Blake · in Technical Issues · 03/15/2008 (4:35 pm) · 3 replies

I am almost there. I have used the example in the GPGT page 153 to @ least was able to change the location of playerB in relation to playerA, however, it seems to be inconsistent. I feel that it is moving the playerB in relation to the world axis, and not in relation to playerA b/c sometimes the player will be in front of the playerA and sometimes the playerB will be behind. I feel it has to do with the fact that I didn't use forward vector when factoring this. Here is some snippets of the code and my question:

%cl2 = ClientGroup.getObject( 1 );
      %cl = ClientGroup.getObject( 0 );

%myPosition = getWords(%myTransform, 0, 2);
		%myRotationVec = getWords(%myTransform, 3, 5);
		%myRotationTheta = getWord(%myTransform, 6);

%myNewPosition = VectorAdd(%myPosition, "0 1 0");

%cl2.player.setTransform(%myNewPosition);

what I want to achieve is code that will make cl2's player face cl1's player, face to face, right in front of him, so that I can have a base setup for animating interactions b/w the 2 players. I think I will need to get the forward vector of cl1's player in order to use this relation, but I don't know how to combine multiple vectors in the setTransform call, nor do I know how to set the forward vector of cl2's player.

Question: How do I set the forward vector and/or transform of cl2's player?

About the author

-IT consultant/tech by day, 'Lone Wolf' game developer by night. -aspired for years to create the type of game currently prototyping. -prototyping indie game engines for years, to various extents, with mixed results. -constantly growing.


#1
03/16/2008 (1:35 am)
Are these ai's? If so, you could just use something like setAim to the other object. I forget the exact method, just do a dump and you'll see it.
#2
03/16/2008 (2:21 am)
These are not bots...they are clients that join a game. In this example, I have specified clients 1 and 2 ( 0 and 1) for prototyping purposes.

edit: I'm going to look @ this setAim function to see if I can learn how to set the forward vector and position of a player by looking @ how the setAim function achieves the effect.

by "do a dump", do you mean look @ the source code via VisualStudio or other IDE?
#3
03/31/2008 (7:57 am)
@Blake: Check out this link. www.garagegames.com/mg/forums/result.thread.php?qt=12612 and garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13786 these relate to rotation and facing another object.

To do a dump. open the console while in game by pressing the '~' key then type: item name or number.dump(); and press the enter key. Ex: 6997.dump(); will display all the values and methods for that object. To get the item names and numbers press F11 and look at the list on the right side of the screen.
Hope this helps.