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 / 3D Physics - Object is way off ground if turned into Dynamic Object?

Author
Message
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jan 2019 14:47 Edited at: 29th Jan 2019 14:55
I've spent way too much time trying to figure this out. I'm not sure what I am overlooking to cause this. Anyone see anything wrong?

It seems the object is being placed on top of the physics object. I don't know how this is useful. I can't use a convexhull, because the leaves stop the tree from falling.



No Physics


With Physics

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 29th Jan 2019 14:56 Edited at: 29th Jan 2019 14:58
I presume the tree suppose to be in the air to begin with. And fall with physics

Try changing shaprstaticpolygon to something like shapeconvexhull or something

I tend to not like the word static in commands if want to move them lol
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jan 2019 15:02
No, they tree is not supposed to be in the air. That is the problem! lol
Convexhull does not allow it to fall over. Not sure why. I even took the leaves off and it just goes to a 45 degree angle and stops.
puzzler2018
User Banned
Posted: 29th Jan 2019 15:03
OK. I'll take a ponder after work. Others may introduce other ideas in the mean time
puzzler2018
User Banned
Posted: 29th Jan 2019 15:09
Just thought ask. There is no scalings. Translation or transitions on the model is there. They are All set to centrel 0,0,0. And scale 1,1,1
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jan 2019 19:19 Edited at: 29th Jan 2019 19:29
this line
"Create3DPhysicsDynamicBody( tree )"
I have found sits all objects in air until gravity has taken effect
and trees should not be dynamic try
Create3DPhysicsStaticBody( tree )

dynamic is only used for like bullets or objects you want the AppGameKit system to dynamically move at any time the physics is updated
static if your going to set its position and not move it
kinematic is similar to static but allows you to move things after

Note: If you want to move a static object like for the next level reposition it then
delete physics body then move the object then setup physics again otherwise the collisions
wont work because they will still be stuck at the first location. Dynamic objects cant be
moved once their physics is set up If you want the tree you break into pieces for example
I would use one static object for tree then when hit replace with parts(more than one) into
dynamic objects. you shouldn't have to apply any forces to them because the individual
parts will push away from each other and the tree bits will fall apart. This is kinda whats
happening.

Sorry that's the best explanation I can give but I understand and still struggle with this at times
fubar
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jan 2019 19:36 Edited at: 29th Jan 2019 19:44
I do not want the tree to be static. The stump is static. The ground is static. The tree needs to fall, and does fall. The issue is the tree is starting on top of the physics shape. Not at its origin point. I am not sure if that is a bug or not.


Convexhull makes it start in the correct spot, but then stops at 45 degree angle instead of hitting the ground. Even when I take the leaves off and am just left with a tree it still stops at a bizarre angle.
puzzler2018
User Banned
Posted: 29th Jan 2019 19:43
Thanks Fubarpk for that nice explanation

Here is a quick example - made with cubes though



Seems like this does exactly what you want to do.

But then its not using your model

Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jan 2019 19:48
Nothing is wrong with the model, as far as I can tell...

Did you use cubes created in AppGameKit?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jan 2019 19:49 Edited at: 29th Jan 2019 19:56
Quote: "I do not want the tree to be static. The stump is static. The ground is static."

it will never sit ontop of another object perfectly nomatter what collision shape you use.

try setting to static then changing it to dynamic when you want it to fall over
dont need any forces it automatically will fall becuase the stump will push against it


NOTE: There are forces being applied to it and that is why it will never work properly any other way
fubar
puzzler2018
User Banned
Posted: 29th Jan 2019 19:56 Edited at: 29th Jan 2019 19:56
Thanks fubarpk

I was hoping that just may have missed the Step3DPhysicsWorld() in the game loop LOL- but this is Golelorn - a great 3D programmer - both of you are...

Yeah - they are AGKs objects

Ill quickly build an external object and give it a test with a non AppGameKit primative
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jan 2019 19:59
Thanks puzzler

I know golelorn creates some good stuff

but convex hulls isn't the right shape to use and will never work proper
you have to delete the physics object and recreate it as I am saying and it will work

what golelorn is trying to do is avoid checking for collisions to change to dynamic I think
but it wont work that way
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Jan 2019 20:30
Can you post the models?
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jan 2019 20:36
Here is what happens:

I press 1 to delete and then create a dynamic physics body SetObjectShapeBox( treefall, .25, 3, .25 )

I have tried to have the stump as a static physics body and no physics body. There doesn't seem to be any difference, either way.




I have also attached the model.

I really appreciate the help.

Attachments

Login to view attachments
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jan 2019 20:38
Wow... OK, I changed the Physics world factor, and got it to work. But I am afraid that will destroy my other physics objects...
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jan 2019 20:50
The bowling in carnival games

the pins drop slightly once update physics is called
but they are dynamic cylinder objects and have a flat bottom

if you change the bottom of the tree so as its flat and theres no wind the object just may fall and
sit ontop without falling over until a force is applied


but i think scaling the physics is the best option and you still might have to with the above if it even
managed to balance on the stump
fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jan 2019 21:03
Quote: "I am afraid that will destroy my other physics objects..."

If you can make sense of the help on physics world factor

recalculating the forces etc for all your other objects should be simply a
multiplication of the values that you are currently using

fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Jan 2019 21:07
Have you set a shape for the stump?
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jan 2019 21:10 Edited at: 29th Jan 2019 21:13
Fubarpk, I just figured that out, and was going to update. It works very fast. Have not yet implemented the trees into my main game, but I did update to delete and recreate the 3d physics, and there is no lag created. Thanks.

bkink, I have tried to create a box, no shape, and no physics on the stump. It doesn't seem to change the results, at all.

edit: attached the stump if you wanted to play with it

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Jan 2019 21:20 Edited at: 29th Jan 2019 21:49
*EDIT*
1: I think it is calculating the shape based on the models center. Which is at the bottom. So the shape extends below the ground which is why it pops up.
2: You definitely need to reduce the physics scale. I used 2
3. I used this code


For some reason it refused to fall over so i had to add some force

Attachments

Login to view attachments
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 30th Jan 2019 00:59
Thanks Blink0k! No more spawning off the ground!
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 30th Jan 2019 03:00 Edited at: 30th Jan 2019 03:02
So, anything I created was also off center. No matter where I put the origin.

Instead of relying on you to fix all my models, I decided to create a box in AppGameKit, then FixObjectToObject(), move the model down 2 units on the Y axis via MoveObjectLocalY, applied physics to the AppGameKit box, and it worked like a charm!!

I really appreciate all the help! This was very frustrating, and doubt I could have worked that out on my own.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Jan 2019 04:49
don't know what program your using for models but in blender

shift + ctrl +alt + c (a long short cut I know) but allows you to centre the origin of a model then just save it
fubar

Login to post a reply

Server time is: 2024-04-19 17:23:43
Your offset time is: 2024-04-19 17:23:43