Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / [Dark Physics] Character Controller

Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 2nd Aug 2006 20:01
I just thought I'd post up my findings, just to hopefully help a few other people who might be a bit confused. I found the character controller a little bit weird to start with, but I think it all makes sense now. I'm implementing it into my game as we speak and after some initial confusion, it's working great.

What first got me is there is only one movement command - essentially move forwards. So what about staffing/side stepping? Or what about jumping, or what if your character has a jetpack?

I've used the following method for my character. Hopefully Mike or someone else will suggest a demo to look at etc. if there is a better solution, but this works for me.

I found the best way to approach the character controller and give yourself plenty of freedom is using vectors to store the speed of your character. So model its speed using X,Y,Z speed vectors and store the angle the character is facing. Here's how I am modelling my X,Z speeds (I've missed out yspd to keep it a bit simpler for now):

As you have to tell the character controller the actual speed of your character (rather than force) you must model acceleration and friction yourself. This is a nice simple way of doing it.

ang# is the direction the player is MOVING so if you're straffing left, ang# should be object angle y(playerObject) - 90, for example. If you're staffing right, it should be object angle y(playerObject) + 90
You can also modify accel# and make it smaller when straffing and running backwards, meaning the player moves faster forwards than in other directions.

Now to actually get your character to move about you would do the following. Firstly, you need to know how fast you're going to move your character. This is simply retrieved from the xspd# and zspd# variables you calculated above. I used vectors as they're a bit faster than pythag:

Now your rotate your character to the direction you want it to move in. This is also derived from the xspd# and zspd# values:

Now you move your character using the physics command:

Then you return it to the angle it should be facing:

My whole process for an 8 directional movement system (staffing, running etc. using the chracter controller) looks a bit like this:

You'll need to tweak that a bit but hopefully that'll help a few people out. I think you can think of the character controller like an object in DB, but with only the MOVE OBJECT command available to do anything with it.

Btw, I used this process to setup my character controller in the first place:

Make sure the centre of your character object is not its feet. If it is, the capsule will be centred on this spot and half of the capsule area will be below your character, making it levitate. If the object centre spot is at its feet use this:

That should help it stand on the ground.

Hope that helps a few people. It's not that complicated, but just requires you to go back to basics a bit.

Mike Johnson
TGC Developer
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 2nd Aug 2006 20:15
The character controller provides a decent starting point and what you have done with this is looking good There are a few extra properties that are currently not exposed which may be useful to you. I'll make sure these new commands are in the next update.
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 2nd Aug 2006 20:40 Edited at: 2nd Aug 2006 20:41
Sounds good. I was a bit skeptical about the character controller when I looked at the command set, but having played around with it, I think it'll be fine for my needs. I'm quite happy to apply forces manually as well as it'll give my characer more control.

Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 2nd Aug 2006 20:56
What would be cool for a character controller function would be an option to make a convex mesh or must a mesh,that way you could have a character model for collision Looks pretty nice fallout. I have done barely anything with character controllers yet though. And Mike, what are these extra properties??( I know they aren't implemented yet,or at least I can't find them...)

Woohoo. DP is finally released!

Login to post a reply

Server time is: 2023-09-24 00:15:24
Your offset time is: 2023-09-24 00:15:24