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 / 3dphysics movement with virtual joystick

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 23rd Jan 2017 16:39 Edited at: 23rd Jan 2017 16:59
I am trying to control a sphere with a virtual joystick, I have tried:

but on running everything disappears from view,I do have the camera 'looking at' the sphere
here is a video of it running using just keys running within a custom editor:


I could of course just use:

But the movement of what is meant to be a rolling ball aint smooth enough
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: 23rd Jan 2017 19:22
The documentation states that the virtual joystick commands.
Quote: "Returns the X value of the virtual joystick at the given index. This will be in the range -1.0 to 1.0 with 0 being centered. "


The return value is between -1.0 to 1.0. This negative value is causing the problem because the SetObject3DPhysicsangularVelocity() command
normalizes the angle values to create a normalized vector used by the physics engine.

Quote: "But the movement of what is meant to be a rolling ball aint smooth enough"


Have you set the rolling friction for the ball and the floor? SetObject3DPhysicsRollingFriction().
You need to set it for the floor as well even though it is a static object.

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: 23rd Jan 2017 19:56
no,havent set friction yet, it is on the to do list for all objects as that was in the back of my mind, a field in the objects type has just been sitting there!!


Do you have any code to sort out this joystick thing then so I can control the balls velocity with the stick?
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 23rd Jan 2017 21:40 Edited at: 23rd Jan 2017 21:49
Ah,I see, had to set a few extra things,to make it stop altogether from rolling, I noticed if you set the linear velocity to 0 on all 3-4 params,it is then your objects vanish from view,however setting them all to something low like 0.01 does the trick! Least for a sphere it does,anyhow have now set the frictions up, tis looking good!



This is just tweaking the camera a tad for first person view,it is still a rolling ball,just out of view! Of course a second virtual joystick would be handy to actually rotate!
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: 24th Jan 2017 04:38
Quote: "Do you have any code to sort out this joystick thing then so I can control the balls velocity with the stick?"


Normalize the values from the joystick before you pass them to the velocity commands.
The coffee is lovely dark and deep,and I have code to write before I sleep.

Login to post a reply

Server time is: 2024-11-24 20:58:04
Your offset time is: 2024-11-24 20:58:04