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.

Newcomers AppGameKit Corner / Trying to get physics hinge for a door going, what am I doing wrong here?

Author
Message
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 17th Feb 2018 17:10
Hey everyone,

I'm not sure if there is anyone that can help out, but for some reason the physics hinge can't seem to act properly, despite most values like the Vector3 for attaching the door to a separate door post cylinder being somewhat alright visually;



There's also another problem at play; I can offset the 3D model in my modelling software to get it to 'attach' more accurately, however that messes with the physics system not understanding which areas should be captured in a physics box for the object shape. As we do not have access to DynamicPolygon physics shapes, it seems I'm a bit screwed? I tried using ConvexHull for the physics shape, but that produces the effect in this video.

The doorway in the wall uses a polygonal physics collision box using SetObjectShapeStaticPolygon(objectid) and the other stuff uses Static physics shapes, except for the player. (Also, the player doesn't collide, the weird wiggle of the door happens even with the player completely some place else.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 17th Feb 2018 17:12
We really need PhysicsDebug tools....
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: 20th Feb 2018 20:22
Please provide a code example.
The coffee is lovely dark and deep,and I have code to write before I sleep.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 21st Feb 2018 01:04
I had parts of it commented for now, as I seemed stuck with what I could reasonably do, but the code was basically this:



The thing that is important to note is how the wall with the hole for the door is actually also an object using a StaticPolygon physics shape (this is required otherwise you would not be able to move through the door way hole).

My guess is that the automatically created physics shape, that's polygonal, for the door, can't match the hole well enough for it to not 'be created' within the other physics object being the wall with the hole for the door.

The more I messed with the model itself, the less the rotation of the door in terms of it's axis made any sense. And the closer the values for positions would match, the more the door would glitch out as seen in the video.

Note: I am aware the door probably should be a physics object that has a box physics shape or maybe a convexhull to not have a static physics object do 'dynamic physics body' things, however literally the only way I can achieve a polygon-accurate physics shape that matches the door accurately (yes, even despite being basically just a simple box shape) is using SetObjectShapeStaticPolygon.

I would love to see the actual physics shape the engine generates for my model to be honest. because maybe there's something glitching there which shouldn't normally cause problems but somehow does. I do use MagickaVoxel to create models, which isn't quite 'clever' in how it merges the cubes you create with it. However, none of my other models made with that ever gave a problem. All of them are accurate down to the cube faces in terms of physics collisions using StaticPolygon where such a physics shape makes sense or in rare cases is required (think about physics collisions within a box or the hole of a window, or a kitchen sink thing that's also part of a wall).

Anyway, long story short, I am open to any and all suggestions. I kind of would love to implement a door like this in my game.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 21st Feb 2018 01:06
Another thing to note: I did test the same model whilst also having it scaled down to so small the generated physics shape should never instantly collide. This sadly still gave the same weird issue we're looking at in the video.
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: 21st Feb 2018 17:04
First thing I notice is that you can not have your door be static.

Create3DPhysicsDynamicBody(door)
SetObjectShapeStaticPolygon(door)

Changing the Dynamic Body your door to a static physics objects is forbidden.
A Polygon collision shape can only be static. So you have changed your dynamic object to static.

Do this instead.

Create3DPhysicsDynamicBody(door)// This line by default creates a box collision shape.
SetObjectShapeConveHull(door)

If your modeling progam does not have your models centered about origin then
the primative collision shapes will be offset(i.e. box, sphere, cone, cylinder, capsule.
Except the convexhull shape and the Static polygon shape whic will be accurate.
The coffee is lovely dark and deep,and I have code to write before I sleep.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 21st Feb 2018 17:52 Edited at: 21st Feb 2018 17:52
Yes, however the video above is with the physics shape for the door already set to ConvexHull and that did not solve the issue. Needless to say I commented out StaticPolygon for that test, but seemed to have the same result.

Also, ConvexHull doesn't have the same effect for a physics shape as the staticpolygon shape does unfortunately. For example, I have a chair which ideal physics shape is essentially a square box physics shape for the legs and lower seat that's like half the size of my model and the upper seat area being a flat upright plane or box, right?

Well, using a ConvexHull physics shape creates a slope between the back of the chair and the actual seat making it impossible to make a character sit on the chair using the Bullet physics commands. That's why I do use StaticPolygon for some DynamicBody physics objects and with the right mass settings it does not go crazy.

Quote: "Changing the Dynamic Body your door to a static physics objects is forbidden.
A Polygon collision shape can only be static. So you have changed your dynamic object to static."


Right, but a static object would respond like door would. It needs to be a dynamic physics body.

My model looks like this, which is really about as perfectly centered as can be:

Attachments

Login to view attachments
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 21st Feb 2018 19:11
I've also had the model offset on the 'X' axis for it not to rotate from the middle of the model by the way, but given up on rotating door for now.
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: 21st Feb 2018 21:16
Quote: "That's why I do use StaticPolygon for some DynamicBody physics objects and with the right mass settings it does not go crazy."


You can not do that. The command SetObjectShapeStaticPolygon() changes your dynamic object to static peroid.
AGK does not have a dynamic polygon collision shape. If you want a more accurate collision shape for a chair you need
to create a compound collsion shape. There is commands for it.
The coffee is lovely dark and deep,and I have code to write before I sleep.
puzzler2018
User Banned
Posted: 21st Feb 2018 21:23
cheers - that helps on another thread lol
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 23rd Feb 2018 22:47
Ok.maybe OT. Do agk2 support non skeletom animation like this door? Or elevator door..or chest
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 24th Feb 2018 15:20
Can someone explain the compound physics shape? I don't need code, but more so some better explanations on how AppGameKit treats them. I suppose a compound shape does not automatically convert a model to a polygon accurate physics shape, correct?
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 24th Feb 2018 15:43
@hoyoyo80:
Quote: "Ok.maybe OT. Do agk2 support non skeletom animation like this door? Or elevator door..or chest"


Yes, pretty sure it does support vertex animations (bone animation loads depending on 'animation name', there's no reason why a properly named vertex based animation wouldn't load. the additional benefit of a skeletal based animation is the ability to change the model based upon direct code affecting specific bones (see the example included in the Projects folder)) , so there should definitely be ways you could 'fake' the physics of a door if you'd really wanted.

As for chests and such, yes you can totally have code do that.

However, I think you might want to learn how to use bone animation, as that also provides you with even more options of how to program things; for example, adding a lid to a bone on a chest as two separate objects could circumvent some of the built-in physics stuff if you write some custom code to go with it actually. Using raycasting you could even write your own custom physics I guess.

I must admit I am a little bit frustrated with the physics system and commands we get to use for 3D. I'm used to physics engines being twitchy and depending on just the right values, but without a physicsdebug function in 3D showing us the generated physics shapes, the points of attachment and such, it is often hard to debug all these values. Especially true because quite a lot is dependent on what physics shape is calculated for my models. I still think the video above is the result of one physics object being spawned within the physics boundaries of another physics object (the wall). But I can't really check that.

Compared to 2D physics in AppGameKit and the ability to have the physics debug function show basically everything what's going on, we really need a working debug for 3D physics too in my humble opinion!
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 24th Feb 2018 22:53
Agree with you. The reason i ask is,sometime animation can save sometime from coding.

Offtopic: That why i request 3d sprite+animation control, small FX thing we just use animation instead of setting up particles.
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: 25th Feb 2018 02:57
Quote: "Compared to 2D physics in AppGameKit and the ability to have the physics debug function show basically everything what's going on, we really need a working debug for 3D physics too in my humble opinion! "


Complain to Paul And Rick Vanner.
The coffee is lovely dark and deep,and I have code to write before I sleep.
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 25th Feb 2018 10:44
from the video it looks like your door is colliding with the door frame. Maybe checking that might help.

if that's not good trying to make the collision shape thinner so the door isn't so thick might also help.
-EdzUp
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 25th Feb 2018 16:15
Quote: "if that's not good trying to make the collision shape thinner so the door isn't so thick might also help."


I would love to try that, however how can I do that? I don't think I can influence the actual collision shape when it is generated automatically?

Quote: "
Complain to Paul And Rick Vanner."


Right... well, I do hope it is somewhere high up on their list for updates to AppGameKit 2. The documentation already mentions the physics debug function for 3D, but it's not implemented yet.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 25th Feb 2018 16:28
Quote: "from the video it looks like your door is colliding with the door frame. Maybe checking that might help.
"


By the way, I've already tried to debug that by moving things to different positions and changing size of the door, however my player model can go through the doorway hole when there is no door without any issues. Therefore it should make sense a door object placed exactly in this hole should not collide. This was actually confirmed already using a model that had no hinge attachment and just a convex hull. However, using a door model that's like 5 times smaller and with a hinge attached (allowing obviously large visual holes) would STILL collide in this jittery way, which is just weird. It means the automatically generated collision hull for the door way causes an effect way beyond what the physics collision suggests when just moving through the door way hole without a door.

Quote: "Offtopic: That why i request 3d sprite+animation control, small FX thing we just use animation instead of setting up particles."


YES. We could definitely use 3D sprites support that are managed pretty much the same way as sprites are in 2D already, but then simply put on a sprite plane in 3D. Not sure why this is not in AppGameKit 2 to be honest. I guess a simple 3D focused 2D sprite animation shader could also be a fix for this. But haven't looked into that yet. I'm aware people already have written their own animation code for sprites in 3D using the plane object, so I am aware we could already do sprites in 3D. But... needless to say some basic support for animating sprites in 3D would be a massive time saver. And make it that much more newbie friendly.

Login to post a reply

Server time is: 2024-11-21 19:26:34
Your offset time is: 2024-11-21 19:26:34