Game Development Community

Mounting a player with a specific node

by Maxime Jouin · in Torque Game Engine · 06/10/2008 (7:04 am) · 0 replies

Hello,

I would like to mount a player to another object, using a specific node on the player (kind of like mounting images). I have a node called mountPoint on the player and I want this specific node to be mounted on the mount0 node of my object. That way, I can animate the player's mountPoint to make it move relatively to the object's mount0. This may sound whacky, but it does have its uses.

The problem is that I can't offset the player correctly so that it positions its mountPoint instead of its Base on mount0. I tried adding this bit of code in the Player::updatePos to no avail:
if (isMounted()) {
	  if( isServerObject() )
	  {
		  MatrixF NodeTransform;
		  S32 MountNode = mShapeInstance->getShape()->findNode("mountPoint");
		  if( MountNode >= 0 )
		  {
			  NodeTransform= mShapeInstance->mNodeTransforms[MountNode];
			  NodeTransform.inverse();
		  }
		  else
		  {
			  NodeTransform.identity();
		  }
		  setTransform(NodeTransform);
	  }
      setMaskBits(MoveMask);
      PROFILE_END();
      return true;
   }

This, theoretically, adds the inverse of the mountPoint to the player's position, thus offsetting it correctly.

What am I doing wrong? Any help is greatly appreciated.