Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Most Efficient Way to Check and Apply Z Gravity?; MAJOR slowdown using AttemptToMove
Topic Started: Dec 1 2008, 12:27 AM (902 Views)
Jerreldulay
Member Avatar
Advanced Member
[ *  *  * ]
Hi guys. The problem I'm having is that whenever my characters in the game end up walking on terrain or going on stairs (cases when their Z values are checked and changed), I lose an unbelievable amount of FPS. All the characters have their own models, and all those objects currently run the script copied from the SDK example:

//apply gravity
zprevious2=z;
falling_speed... etc. etc.

//Do the collision detection and response
free_position=AttemptMoveToPosition(etc. etc. etc.)

What this code should do is allow characters to walk on terrain and stairs while adhere to the solid objects. This is fine and dandy, and works, except for when I have more than one character running this code, the game lags terribly.

(The difference between letting AttemptMoveToPosition check for changes in gravity and Z downward movement is around 25 FPS when there are 4 models on screen)

If I disable this code's ability to use gravity, therefore changing the position which AttemptMoveToPosition checks, the game runs at normal speed. The characters will walk UP ramps and terrain, but, of course, will not walk back down the terrain.

I have tried using CheckSweptEllipsoid etc. etc. so that the gravity will only be active when there is nothing below that character, but it didn not seem to work for me.

My question is: is there a faster method to obtain the effect of walking on solid objects and terrains, and if not, how can I use CheckSweptEllipsoid to toggle gravity on and off for a model. I really only want to check the value of one spot at the feet of the character, for gravity purposes.

Thanks tons for time and assistance. I really appreciate it.

Edited by Jerreldulay, Dec 1 2008, 12:29 AM.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
I don't know. I have about 20 charcters on screen at once, and they don't give me any problems, even though I'm using the same code (I actually just changed it to only call AttemptMove once.)
Blog|EHS
Offline Profile Quote Post Goto Top
 
Jerreldulay
Member Avatar
Advanced Member
[ *  *  * ]
Seriously? Well, hearing that makes me feel like I have some chance at making it work alright. The feasibility of my game was starting to fall through the floorboards since this issue started...

Could the problem be with the height and hip_height values of my objects? I've been adjusting them to no end but the effects are seemingly unpredictable.

I'm hoping someone can offer insight as to what I can adjust to get it all to work right. I seem to lose about 5-10 FPS for every character using the AttemptMoveTo, etc. etc.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
This happens because the gravity pushes the ellipsoids through the ground, forcing many iterations inside the collision procedure.

Here is your egg collisions:Posted Image

As you can see you are forcing it to always apply the collisions, even when the base of the player is at the wanted distance.

VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
yeah skarik, i kind of dont know the math, at least we know the problem :P
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Jerreldulay
Member Avatar
Advanced Member
[ *  *  * ]
Thanks! I'm very glad I know what's happening now. I've got to think up a way to kill the gravity when its not needed, right?
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
Jerreldulay
Dec 11 2008, 01:33 AM
Thanks! I'm very glad I know what's happening now. I've got to think up a way to kill the gravity when its not needed, right?
nah its just a litle bit of math needed, to see the real distance from the ground the ellipsoid should be pushed, i dont know the exact formula for it, but im sure mysteriXYZ does, or Dr. Best maybe, if not, no need to worry, there are ways of finding out these things ;)
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Jerreldulay
Member Avatar
Advanced Member
[ *  *  * ]
Thanks heaps. I as hoping I'd find a logic-based method as opposed to a math-based method but I suppose math may be the most plausible route to take... I suck at math.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
Okay I found the solution: (i'm suprised it took me this long to figure it out)

have an ellipsoid with an origin near the chest, a radius equal to the distance from the chest to the head. This way the ellipsoid will not extend below the knees.

The benefits to this are:

Free movement on non-steep ramps

Automatic mantling on surfaces lower than the knees

Automatic steep ramp repulsion

And more :D
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Jerreldulay
Member Avatar
Advanced Member
[ *  *  * ]
Eanbro, interesting suggestion. It sounds like it makes sense but I'm not entire sure how to implement it. I've tried adjusting values of my ellipsoid but to no avail. Are you saying I should offset the origin of the whole thing? Thanks.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Jerreldulay
Jan 6 2009, 03:43 AM
Eanbro, interesting suggestion. It sounds like it makes sense but I'm not entire sure how to implement it. I've tried adjusting values of my ellipsoid but to no avail. Are you saying I should offset the origin of the whole thing? Thanks.
No, he means start at a higher position.

Well, I think he does. You still have to expand it to touch the toes.
Blog|EHS
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
No. You should have the ellipsoid like this:

Posted Image

Ask Gandalf 20000, he got it to work.
Edited by Eansis, Jan 6 2009, 09:29 PM.
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Jerreldulay
Member Avatar
Advanced Member
[ *  *  * ]
Thanks heaps for all your time and help to everyone, I really appreciate it. I'll be spending time trying to get it working today and post results. I'll try Gandalf20000 if epic failure ensues.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Eanbro
Jan 6 2009, 09:29 PM
No. You should have the ellipsoid like this:

Posted Image

Ask Gandalf 20000, he got it to work.
Hey, that reminds me of Stickman's old collision!

I got rid of it because it let me climb slopes.
Blog|EHS
Offline Profile Quote Post Goto Top
 
Reikyrr
Forum God
[ *  *  *  *  *  * ]
skarik
Jan 7 2009, 04:06 AM
Eanbro
Jan 6 2009, 09:29 PM
No. You should have the ellipsoid like this:

Posted Image

Ask Gandalf 20000, he got it to work.
Hey, that reminds me of Stickman's old collision!

I got rid of it because it let me climb slopes.
Your new collision lets me walk on a one pixel edge :P
~Inspirational quote~
Offline Profile Quote Post Goto Top
 
Go to Next Page
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply