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 / Physics issues

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Dec 2017 00:07
I am trying to do a pinball table thingy. Attached is a project highlighting a problem i have

What it does is it reads a .obj file and separates out the groups into individual .obj files in the Documents directory and then loads them in.
Right now it just has floor and ball. It fixes the ball to the floor and rotates the floor. It then unfixes the ball
It sets the floor to be a static physics object with a box shape

When you hit the space bar it will make the ball a dynamic physics object with a sphere shape and it will fall.

Now if you run the attached app and use the arrow keys to get a good side on view and then release the ball you will see that the ball stops and rolls WAY before the floor object.

What am i doing wrong? Any help or advice is always appreciated

Attachments

Login to view attachments
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 14th Dec 2017 00:20 Edited at: 14th Dec 2017 00:22
You have an awful lot of o.o in your code!
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Dec 2017 00:25 Edited at: 14th Dec 2017 00:26
There's a lot of debug stuff that has crept in but basically it ends up being two objects; the floor and the ball.
Do you have any suggestions?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Dec 2017 01:00
It's the origin. It includes the origin when making a hitbox
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 14th Dec 2017 01:25
Nicely spotted!

BTW, I noticed that the box edge facing the viewer seem to be missing, most likely turned inward. (stupid normals)
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: 14th Dec 2017 02:56
If I remark this line in your code it works.



You do not need to call SetObjectShapeBox(g) after calling Create3DPhysicsStaticBody(g) .

Create3DPhysicsStaticBody(g) command creates a triangle mesh collision shape for the object and is the
best collision shape for static objects. Triangle collision mesh shapes are for static objects only and give the
fastest results in the physics engine for static objects. This would be easier too see if there was a debug mode
that would show the collision shapes but Paul did not have the ability to draw wireframe at the time I added the physics.

The coffee is lovely dark and deep,and I have code to write before I sleep.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Dec 2017 03:11 Edited at: 14th Dec 2017 03:12
Ok i did that but the ball just falls straight through the shape (Press spacebar to drop ball). Even when i set the shape. Any ideas?

On the debug: I wonder if he could use a shader to do that

Attachments

Login to view attachments
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: 14th Dec 2017 03:26
Quote: "Ok i did that but the ball just falls straight through the shape. Even when i set the shape. Any ideas?"


I do not understand it is working for me. Ball hits and rolls.

What is happening is that you are adding the ball object to the floor object with the
FixObjectToObject() command and then creating a collision shape for the object floor.
It is creating a box shape that includes both objects in the calculation. The result is a larger
box shape. If you just call Create3DPhysicsStaticBody() it is creating a polygon collision shape
around both objects. I would suggest not using FixObjectToObject() command.

Quote: "On the debug: I wonder if he could use a shader to do that"

That is up to Paul to fix.
The coffee is lovely dark and deep,and I have code to write before I sleep.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Dec 2017 03:39 Edited at: 14th Dec 2017 05:13
Did you try it with the one i attached in my last post?

I fix the objects to the floor so i can easily rotate the floor and then everything else rotates in place.

Once it is rotated i Unfix (Check the UnFix() function) them from the floor and then apply the physics

Attached example with just the ball and floor

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Dec 2017 06:29 Edited at: 14th Dec 2017 08:20
Ok i figured it out. I had to;
1. Load in the models
2. Reset their pivot point
3. Fix them to the parent (floor)
4. Rotate the parent (floor)
5. Unfix them from the parent (floor)
6. Make them physics objects
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 14th Dec 2017 19:24
Strange, I tried using Stab's initial suggestion only and worked ok for me too.
Is there a platform or AppGameKit version difference here?
I'm on W10X64, with the most recent AppGameKit version 2017.12.12.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Dec 2017 21:10
Nah. It's just that i made changes in the second version i posted which broke it

Login to post a reply

Server time is: 2024-11-24 05:34:48
Your offset time is: 2024-11-24 05:34:48