Game Development Community

Need help on player helper drone...

by Bill Vee · in Technical Issues · 11/27/2004 (6:38 pm) · 2 replies

I have coded a drone that helps the player by shooting projectiles at enemies.
The problem I have is that it updates it's position in a kinda jerky manner , like it is being teleported about the player.

The two methods I have tried are a scheduled function and adding a console script to the player processtick but they both produce this jerky teleport motion.

I really want it to be a smooth motion.
I have tried a "ramping" type effect but this produces a lag effect when the player is moving.

What I think I need is a way to change the mount position on one of the players mountnodes on the fly.
What I mean is the actual x,y,z of the local mount point not the mount# as the poisition is very arbitrary relative to the player.
I have seen the Getnodeposition thread but I need something more like a Setnodeposition function.

#1
01/03/2005 (4:51 pm)
Well since no-one could help me, I figured it out myself.
Had to forget the built in mount function and adapted the code I found here.


Moved code to Player instead of sceneObject and modified this code from updatescenemount()
from

if(!mMountedObject) return false;

MatrixF res;

res.mul(mMountedOffset, mMountedObject->getTransform());
setTransform(res);

res.mul(mMountedOffset, mMountedObject->getRenderTransform());
setRenderTransform(res);

return true;

to


if(!mMountedObject) return false;
MatrixF res;


	Point3F pos;
	Point3F newpos;
	Point3F rot(0,0,0);

	MatrixF objToWorld = mMountedObject->getTransform();

	mMountedOffset.getColumn(3,&pos);
		objToWorld.mulP(pos, &newpos);
		res = mMountedObject->getTransform();
		res.setColumn(3,newpos);
		setPosition(newpos,rot);
return true;

Now I can mount any object to the player and give it and arbitrary position relative to player and it will turn and rotate with the player.
The position can be altered on a per processtick basis and it moves very smoothly with the player.

The reason I needed this was for a drone-like little turret object that fires at the same target the player will or any anemy that comes in it's "scan" range.
#2
01/04/2005 (7:28 am)
Very cool... glad you posted your results up