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.

AppGameKit Classic Chat / Still not getting the 3D physics : Example character controller..

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 26th Jun 2016 12:12
I a still unable to get to grips with the 3d physics, I am trying to incorporate it properly into my 3D editor but no matter what it will not work right, I have finally gotten to write a small example of one of the problems:
character controller



Some of the code is taken fro the editor, I need to know where I am going wrong here, running this will create a pretty erratic player.. I had simply:
CreateVector3( 0.0,0.0,0.0) like I had seen in some earlier example but this wont work also! Clearly I am not understanding something!!
Hail to the king, baby!
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 27th Jun 2016 03:02 Edited at: 27th Jun 2016 03:04
Did you look at the example I posted here.
https://forum.thegamecreators.com/thread/216683

Please down load the example and run it. Then study the code.

First thing The box you created to be the player is too small. There is a minim size of an object for physics to be stable.
The character offset vector is the amount you need to offset the character object based on its center.
For example the masked soldier model I used in the demo has its feet at origin and is approximately 72 units tall so it needs to be offset on the Y by 36.0 units.
The offset vector would be zero on the Y if the model was centered about origin. So you box which is the player would just use all zeros for the offset vector.

The object orientation vector allows for the rotation of the masked soldier in the demo. The masked soldier model is looking down the -z axis so we turn him
by using objectOrientationVec = CreateVector3( 0.0, 0.0, -1.0 ) to look down the positive Z axis.
These 2 vectors allow you to use any model by making adjustments for use with the character controller.
Your box would use all zeros because it does not need to be turned.

In conclusion you need to make the player box bigger e.g. ( 16.0, 72.0, 32.0 ) for stable physics.
Or change the scale factor when creating the physics world.

P.S. Your player object needs to be positioned above you static floor so it can fall onto it once the loop starts.
The coffee is lovely dark and deep,and I have code to write before I sleep.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 27th Jun 2016 10:22 Edited at: 27th Jun 2016 10:31
if I create a box then that has a size of just 1,1,1, how many of these AppGameKit units is this, just 1? Also how many units do you know the soldier model is AppGameKit wise when making it, is there some ratio? I know the sizing is a bit different in blender, a default box in that is actually twice the size of an agk box! I had of course looked at the examples but not knew about unit size really, so if I was to use an AppGameKit box as the player controller , what is the smallest I can make?
for example
createobjectbox(objID,sizex#,sizey#,sizez#)


what then is the lowest that sizex#,sizey# and sizez# can be to make it valid for the char controller? In my editor these values are set to a default of just 1!!
Obviously I need the minimum to be not as low then for these physics
Hail to the king, baby!
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 27th Jun 2016 14:37 Edited at: 27th Jun 2016 14:40
The masked soldier model is from Game Guru. I can see the size of the model in a modeling program called Fragmotion.
I can also see the rotation of the model and where origin is in relation to the center of the model.
The default scale factor for the physics world is set to use models of this size. This is the most common size of character models.
The smallest stable size for a dynamic object at the default scale factor is approximately 3.5 units.
This minimum size would not be for the character but rather the smallest visible dynamic object e.g.(ammunition clip).
The way the character controller works is it creates a capsule shape based on the size of the model. Your model gets positioned and
rotated to line up with the capsule.

I do not use blender so I do not know about sizing problems with it.
All the other modeling software shows the model the same size as in AGK.

P.S Did you run the Character Controller Demo I posted?
The coffee is lovely dark and deep,and I have code to write before I sleep.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 29th Jun 2016 03:25
Did you get it to work?
The coffee is lovely dark and deep,and I have code to write before I sleep.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 4th Jul 2016 15:39
Right, still frustrated with this, it is true I had the sizes wrong,which I adjusted in my editor,but I still got this flicker, so I took the code that created the character controller from your example, taking out the animation commands as I wasnt using them: firstly the model:

https://drive.google.com/open?id=0B4KG5czzbkfldmZxUkR4UW1FSFE

This model is just the soldier exported from fragmotion as a .obj, so without the anim frames.


Now the code:




This code is chunks of yours with a more simple main loop, just the basics needed to see what is going on!

If you run this, keep pressing a until the character falls off the edge, now when I do this, the character falls, but I get a flicker and see more than 1 model!

However if I put the sync() before the Step3DPhysicsWorld() command, the flicker vanished.
Hail to the king, baby!
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 4th Jul 2016 16:38
The flicker is not a bug in the character controller. It is how your positioning the camera.
If you are positioning the camera based on the position of a physics object you need to do it after
physics has updated the position of the object.
If you move the 2 lines where you position the camera too below the
step physics command it will work smooth.

The coffee is lovely dark and deep,and I have code to write before I sleep.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 4th Jul 2016 20:10
Ah, it was that simple! Tnx.
Hail to the king, baby!

Login to post a reply

Server time is: 2024-05-05 09:22:39
Your offset time is: 2024-05-05 09:22:39