Game Development Community

Player movement

by Ron Yacketta · in Torque Game Engine · 08/20/2002 (4:36 pm) · 27 replies

All,

I have been caught up in playing the likes of Dungeon Siege and NeverWinter Nights. Just recently I got this fire inside to add clickable movements to TGE, that is click a location on the screen and the player will move to it.

I started to dig around the AI code for some clues, but man that is a muck in their ;)

I was wondering if we could open up some dicussion regarding this topic? I am sure other game types (especialy RPG's MMORPG's etc) would be interested in this.

So, to start this off. What do you think would be the most sane/TGE conforming way to add such a thing to TGE?

Regards,
Ron
Page«First 1 2 Next»
#21
09/20/2002 (6:04 pm)
Give me (us?) a few days or so, I am not totaly satisfied with what I have. I would like to expand it a bit more and allow the player to select an object which s/he would move to, equaly so; if it is an enemy (not sure how yet) attack! etc..

Think Dungeon Siege/ NWN, that is the type of player control I am shotting for. is it a daunting task? a big YUP their, but I belive most if not all of it can be accomplished.

I will definatly post what i have when i feel it is worth posting, and I also hope the community will rip it to shreads and find easy ways of doing this as well as bugs etc. I hope that what i provide will be beneficial to those make a RPG/RTS/MMORPG etc.

Regards,
Ron
#22
09/25/2002 (7:00 pm)
I have made a couple of changes to getRPGMove() (which is basicly the samething as getAIMove() that TimG added to aiPlayer.cc)

in RPGPlayer.cc (aiPlayer.cc)
after the includes I added:

// shamelessly stolen from player.cc
static U32 sCollisionMoveMask = (TerrainObjectType      | InteriorObjectType    |
                                 PlayerObjectType       | StaticShapeObjectType | 
								 VehicleObjectType      | ForceFieldObjectType  |
                                 PhysicalZoneObjectType | StaticTSObjectType);

then further down in getRPGMove() (getAIMove()) after

// Use the eye as the current position.
   Point3F location = getPosition();
   Point3F rotation = getRotation();

I added

Point3F mLocation;							// variable to hold my current location (EYE location that is)
   MatrixF myEyeTransform;						// Variable to hold my EYE transform
   getEyeTransform(&myEyeTransform);			// get my EYE transform
   myEyeTransform.getColumn( 3, &mLocation );	// get the coords of my EYE location
   RayInfo info;								// variable to store castRay info
   
// Disable collision detection to allow the following collision test to work properly   
   disableCollision();

// Check to see if we would collide with anything in our path to our defined
// destination. If we do collide, set our movedestination to the point of colision   
   if( !(mMoveDestination.isZero()) && getContainer()->castRay( mLocation,  mMoveDestination, sCollisionMoveMask, &info)) {
			mMoveDestination.set(info.point.x,info.point.y,info.point.z);
	}
// Re-enable collision detection
	enableCollision();

then I replaced

if( location == mLastLocation) {
            throwCallback("onMoveStuck");
            mMoveState = ModeStop;
         }

with

// Ugly hack to stop the player movement when they within 1 unit of their destination
// I noticed that the code thinks the player is still to move if they collide within
// something and are greater that 0.25 units away.
		if (mFabs(xDiff) < 1.0f 
		&&  mFabs(yDiff) < 1.0f) {
            throwCallback("onMoveStuck");
            mMoveState = ModeStop;
         }

Thats all for the changes, now what does it do?

well I noticed that if you set a bot on its way and it hits (collides) with something the dumb thing keeps on trying to move. The reason for this is simple

if (mFabs(xDiff) > mMoveTolerance || mFabs(yDiff) > mMoveTolerance)

if the mFabs is greater than 0.25 keep a trucking.
So, what I did is checked to see if the bot would collide with anything in its path, if so set mMoveDestination to the point of collision. Then I check to see if the bot is within 1.0f units of the desired destination, if so stop moving.

Now that I am thinking about it, I could have just changed mMoveTolerance to 1.0f.

Regards,

Ron
#23
10/02/2002 (6:17 am)
Am I the only one interested in this? There are no current projects (RPG/RTS/MMORPG etc..) that would require such a beast?

I am nearly complete with this, just need to shore up a couple minor issues and I will rip out the relevant code and toss it in as a resource.


-Ron
#24
10/02/2002 (9:11 am)
No, sir!

I am extremely interested in this. I'd be happy to help you code on it (my project has very similar goals in term of unit selection/command), or at the very least, use the fruit of your labors.
#25
03/04/2003 (8:01 pm)
Ron, what was the result of all your hard work? Do you have point/click movement?

I'm interested in a "follow" system, whereas I can take one unit, and have him follow the leader. If the leader moves foreward, the unit will also move foreward the same delta. For sake of simplicity, I think grabbing the delta in positions, and having the unit interpolate to that position given his maximum velocity is the best approach.

So, how did this turn out?
#26
03/04/2003 (8:26 pm)
What most games do is they give each follower an off-set value from the position of the leader. So follower number one stands one step behind and to the right, for example. Follower two stands one step behind and to the left. And so on.

What pattern you choose depends on the game. Or you could do like Baldur's Gate and let the player choose between a list of patterns, like arrow head, concentric circles, square, etc. You obviously have to rotate the pattern according to the direction the leader is facing.

Also, you have to include some form of delay so that the followers don't copy your every little move.

Anyway, great initiative to start work on mouse controlled movement. I'm probably going to need that for my next project.
#27
03/05/2003 (5:02 am)
Yes, it is out ;) have a gander at the resource section or better yet
here

-Ron
Page«First 1 2 Next»