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 Studio Chat / [SOLVED] "SetObject3DPhysicsAngularVelocity" and "SetObject3DPhysicsLinearVelocity" not working properly.

Author
Message
Vikingblade
2
Years of Service
User Offline
Joined: 16th Jan 2022
Location: UK
Posted: 16th Apr 2024 12:31 Edited at: 16th Apr 2024 17:05
I am working on a 3D game and the physics is set to zero gravity. I have set up the code, see below, to rotate the player ship left or right. The code snippet below shows how I've set up the do loop to make this happen. When I run the game it seems to work fine at first, but after a few seconds the player ship does not rotate any more even when I press the associated key. I have run the debugger to see what's going on and the program continues to run after the player ship will no longer rotate. When I press the rotate left or right keys the SetObject3DPhysicsAngularVelocity commands continue to execute but the player ship will not rotate. The same is happening with the SetObject3DPhysicsLinearVelocity commands in my program when I'm pressing the keys to move the ship forwards and backwards.

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 16th Apr 2024 17:40
vb, re: your edit here and additional inquiry thread, you're on post moderation presumably due to relatively low post count since joining which means your posts need to be manually approved by a moderator until the system removes that requirement.
Vikingblade
2
Years of Service
User Offline
Joined: 16th Jan 2022
Location: UK
Posted: 16th Apr 2024 17:42
I've switched the gravity on, modifying the ' Set3DPhysicsGravity(0,0,0) ' to ' Set3DPhysicsGravity(0,1,0) ' just before the do...loop in the Code Snippet in my first post, and the problem has disappeared. Looks like there's a bug when setting all x, y, z gravity values to 0.
Vikingblade
2
Years of Service
User Offline
Joined: 16th Jan 2022
Location: UK
Posted: 16th Apr 2024 17:47
RE: Virtual Nomad

Thanks for letting me know, I thought there was a problem with the server.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Apr 2024 23:21 Edited at: 16th Apr 2024 23:22
I would assume that SetObject3DPhysicsFriction()/SetObject3DPhysicsDamping() or the default friction/damping would have an impact on that
Vikingblade
2
Years of Service
User Offline
Joined: 16th Jan 2022
Location: UK
Posted: 17th Apr 2024 12:37
RE: blink0k

I don't have ' SetObject3DPhysicsFriction()/SetObject3DPhysicsDamping() ' commands in my program but have looked in to any default settings related to those. From what I understand about ' SetObject3DPhysicsFriction(), ' the player ship object would need to be moving against a surface, which it doesn't as it's set in space and is not touching anything. ' SetObject3DPhysicsDamping() ' - damping is a slowing effect that operates over the whole leading surface of an object. We may think of damping as the effect of air (or water) resistance on a moving object, which there is none. I decided to use the ' GetObject3DPhysics... ' commands ( see snippet below ) to store these values in variables so I can watch them in the debugger as the do...loop executes. The values are ' 0 ' for each one during each execution of the loop even when the player object doesn't move anymore.

Scribble
7
Years of Service
User Offline
Joined: 2nd Apr 2017
Location:
Posted: 22nd Apr 2024 23:59
Can you post a simplified version of the game project?
ando
4
Years of Service
User Offline
Joined: 21st Feb 2020
Location: Australia
Posted: 24th Apr 2024 11:00 Edited at: 24th Apr 2024 11:24
Hi Vikingblade.
Maybe something here will come in handy.

EDIT: actually, if you already got it working then disregard.



I gave it a test by throwing it in an attract / repel demo I made a while ago.

It might need to be adjusted to work in space with the ship being at all kinds of angles.

BASIC appeared in May 1964. Lightning flashed, the wind roared and the Earth moved.
And nine months later I was born.
So here I am.
I am Basic.
Code is in my genes.
Vikingblade
2
Years of Service
User Offline
Joined: 16th Jan 2022
Location: UK
Posted: 24th Apr 2024 19:34
RE: Scribble

Here is a simplified version of the project with all that is needed to re-create the bug:

Vikingblade
2
Years of Service
User Offline
Joined: 16th Jan 2022
Location: UK
Posted: 24th Apr 2024 19:46
RE: ando

Hi and thanks for the reply.

From your first code snippet, ' SetObject3DPhysicsAngularVelocity(playerShip,0,-1,0,50) ' works in the code but doesn't do exactly what I need it to do. It just sets a static speed to the playerShip no matter how many times you press the key, but I'm trying to increase the playerShip rotational speed with each key press. This is why I use the variable ' playerShipAngularVelocityY ' instead of a set value such as ' 50 ' Each key press is increasing ' playerShipAngularVelocityY ' or decreasing it depending on what key is pressed.

I have posted a simplified version of my project in my last post above, so you can see what happens when you attempt to increase or decrease speed. It just freezes but the program is still running as you can see "Angular Y Speed: " on the screen continuing to increase or decrease.
ando
4
Years of Service
User Offline
Joined: 21st Feb 2020
Location: Australia
Posted: 24th Apr 2024 19:58 Edited at: 24th Apr 2024 20:09
This post has been marked by the post author as the answer.
Yes, I understand.

With the object freeze thing, try this command...

After this Create3DPhysicsDynamicBody(playerShip)

Add this
SetObject3DPhysicsCanSleep(playerShip,0)
BASIC appeared in May 1964. Lightning flashed, the wind roared and the Earth moved.
And nine months later I was born.
So here I am.
I am Basic.
Code is in my genes.
Vikingblade
2
Years of Service
User Offline
Joined: 16th Jan 2022
Location: UK
Posted: 24th Apr 2024 23:01
RE: ando

That seems to work ! Thank you !

I'm relatively new to 3D games programming and physics, so I'm working out and playing with all these commands as I go. I have the tutorial guides "Hands on AppGameKit Studio" volumes 1 and 2 to work my way through as well.

I'll have to read up more on ' SetObject3DPhysicsCanSleep( objID, canSleep ) '

Login to post a reply

Server time is: 2024-04-30 14:59:42
Your offset time is: 2024-04-30 14:59:42