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 objects and physics

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 8th Aug 2016 18:00 Edited at: 8th Aug 2016 18:47
I have rewrote a 3d editor several times,but run into the same problem,everything objects and physics wise are fine until I want to control them, then eventually they stop moving,or on some runs dont move atall,
initial tests when developing the physics and editor look like so:


no problems atall, however when it comes to controlling my own object via physics,I get stuff like this:




As you see it is pretty lucky to even work, even though all physics settings are the same as the previous example video!
the piece of code running the last video is simply:




This is at the top:

And nothing more,I am calling Step3DPhysicsWorld() before sync() . Both examples are using the exact same editor to create each 1 and the same functions to run them,,the latter simply gets the sphere passed to their control
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: 9th Aug 2016 02:57
You must set the object so it can not sleep using the SetObject3DPhysicsCanSleep( objID, canSleep ) command
before you can set the velocity for the 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: 9th Aug 2016 07:54 Edited at: 9th Aug 2016 11:30
Ok,I had missed that this time around, but when I use this, then it never stops of course, but when I put in:
if jy#=0
SetObject3DPhysicsLinearVelocity(player,0,0,0,0)
endif

The sphere totally vanishes! Which is what I always find

if I simply say:
SetObject3DPhysicsLinearVelocity(player,0,0,GetVirtualJoystickY(1),1)

in a loop, then it vanished straight away coz it would be 0.0 at the beginning,so I rather then just want to know how you slow down an object that cannot sleep! without it vanishing!
I had this before HERE . Using the code given to me, and thought I had solved it by moving the step3dphysics() to the top
But found that when it came to setting the velocity of the ball to complete zeros,as I wanted if the ball fell off the level, then the ball would totally vanish,with its physicscansleep set to 0
At the time of it happening then I display the balls y coordinate at all times, and noted the readout after it vanished as being something like 1.F0xxxxxx whatever it was! very odd readout, like it leaped into some hex-dimension!
All You need is a ground with static physics and a sphere with dynamic physics,the sphere of course has it cansleep thing set to 0, a virtual joystick, and the use of the SetObject3DPhysicsLinearVelocity() command tied in with the joystick, and try to set its velocity and speed to zeros when you want to!
So with them things set,imagine if say you fell of the edge,wanted to reposition the object plus of course make sure all its velocity is zeros! ,or simply not keep moving but 'walk' a step or 2..it is at that point the object disappears and has a strange coordinate readout. I am aware of the character controller all too well and had gotten that working,but in this case I just want to roll a sphere around with the joystick using physics! But having its cansleep set to zero whilst also being able to stop it dead when needed
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 9th Aug 2016 13:00 Edited at: 9th Aug 2016 13:37
Right,after a bit of coding, I am back to this:



As in the last link with the code getting called upon pressing t to test the level,


I did have the part:

In the main loop before the sync() but it makes nothing visible onscreen and actually crashes agk2
the problem I have is stopping the ball when needed, as in when you are not pressing joystick up/down/left/right!
On the plus side I got pretty darned good at writing level editors! This last one just standing at 770 lines of code,considering my first attempt at a 3d editor ended up being 2008 lines without physics,coz it never existed....this is some leap!
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 9th Aug 2016 14:56 Edited at: 9th Aug 2016 15:01
ah! ok after a thought of what that was doing,I realised I needed something more like:




which gives me:



added scrolling the middle mouse wheel to zoom!
This is good enough for what I want. But it would never get it totally stopping instantly in the case of moving a fps character for instance, but that is what the physics character controller is for!
Now crucially time to add the ramps back in!
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: 9th Aug 2016 22:15
I will agree that the name of the command is confusing because it would seem that you are setting the current velocity
of the object. You will have to blame TGC for that as I had a better naming convention, but they changed it.
The SetObject3DPhysicslinearVelocity() command does not set the objects velocity it actually applies a velocity
to it. So using all zeros does not apply any velocity and will not stop the dynamic object because the physics engine
is applying forces. You need to apply an opposite velocity to the current velocity to slow it down. Once its velocity
slows to below the threshold and it is allowed to sleep it will stop until you wake it up again. You can adjust the thresholds
for an objects ability to be put to sleep by the physics engines with these 2 commands.

SetObject3DPhysicsDeactivationTime AND SetObject3DPhysicsSleepingThreshold
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: 9th Aug 2016 23:13
I had tried these, but it ending up slowing down/stopping,then reversing!! maybe I got some logic wrong,anyhow am am now finding hard to get a balance between speed,gravity and the Create3DPhysicsWorld() command, trying to find a balance as I am finding it either to easy to get up a a ramp object,or too hard, messing with the speed of the velocity applied is either the same in conjunction with whatever gravity and that,too slow and wont get up the slope, or too fast and hard to control with joystick but easy to get up slope, mixing in the gravity in all of this is near impossible and will be hit and miss!
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: 10th Aug 2016 00:27
I would leave gravity at the default by not setting the gravity. The problem may have to do with the
scale factor. What is the size of the marble/ sphere you are using? There is a proper explanation in the commands description
of what to set the scale factor at depending on the size of the objects.
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: 10th Aug 2016 09:13
the scale is just 1, but last time I delved into scale stuff, I tried scales from 1-80 and it made no odds! do you have a model of a block/cube that has the lowest possible scale/size needed so I can reference it?
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: 10th Aug 2016 13:56
I will ask again what size is your sphere? I would make it 32 AppGameKit units and do not change the scale factor or
the gravity. This will give you the best visual results.
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: 10th Aug 2016 19:37
sorry it is hard to say the size as I had created it in blender, though maybe not now and just use agk's to set the size to 32 and test from there
Hail to the king, baby!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Aug 2016 20:49
Quote: " I had created it in blende"

Why not use CreateObjectSphere?
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 11th Aug 2016 02:12
ok,I think I have a problem in that I can only really move in 1 direction at a time, this is especially true for the character controller()
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: 11th Aug 2016 14:18
Quote: "ok,I think I have a problem in that I can only really move in 1 direction at a time, this is especially true for the character controller()"


This is up to Paul to answer at this point. I will no longer be hanging around these forums.
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-25 04:22:09
Your offset time is: 2024-11-25 04:22:09