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 / trying to use SetObject3DPhysicslinearVelocity()

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Jul 2016 13:31
I am trying to work out how to move and jump using SetObject3DPhysicslinearVelocity()
The problem is how it works, I cannot both move left and jump, unless there is a way?
So far I am simply doing.



But of course it stops moving left if I jump or the other way around!
Hail to the king, baby!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Jul 2016 14:02
If it's a character, you should use the character controller.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Jul 2016 15:21
I really wanted to roll a ball around, so not really a standing/walking character... but i dont think it is possible is 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: 12th Jul 2016 16:29
Quote: "I really wanted to roll a ball around, so not really a standing/walking character... but i dont think it is possible is it?"


Yes you can roll a ball around. Your code snippet does not show jumping.
FYI the SetObject3DPhysicslinearVelocity command take direction vectors in world space.
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: 12th Jul 2016 16:42 Edited at: 12th Jul 2016 16:45
ah sorry,i simply have this for jumping:



So the player object is a sphere and has dynamic physics, how would I roll this around and jump without one effecting the other!
Hail to the king, baby!
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jul 2016 16:57
Sample the current physics velocity first, and apply the X Y and Z velocity after adjusting it for movement and jumping. I have a example...



There is no de-bounce on the jump (mb=1), but you probably have your own setup for that, as you'd only want to jump if the ball is touching the ground.
The code is dark and full of errors
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Jul 2016 17:03 Edited at: 12th Jul 2016 17:11
ok I will look at t thanks,yeh I use it in conjunction with raycasting
hmm.. what is the var mb for?!
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Jul 2016 17:21 Edited at: 12th Jul 2016 17:35
well,tried incorporating your code:



that is the whole function I have, I had to put a digit of 2 to the vars as I was already using the var names. What happens now is that the sphere totally vanishes offscreen, I also didnt know how the ready var was used so set it to 1 as a global :/

I have recently yet again recoded this 3d editor and just trying to make sure it is ok every step of the way:
here is what I had so far with the problem!


I had changed to a sphere after the video was made
But in that I am of course controlling the rogue cube
As you see it is just in the early stages yet again!
Hail to the king, baby!
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jul 2016 18:15 Edited at: 12th Jul 2016 18:17
The MB var is the mouse button, that was just copy pasted from an old test thing I did. Also, remove that If ready>0 condition, that's probably causing problems. I used that so manual speed adjustments could be disabled - like you could use that and set it to 0 if the ball is in the air, then it would move with physics alone, then set ready to 1 when on the ground. I've attached the whole test, it's a very simple rope or snake test, spheres following a sphere controlled by the player.

Editor looks good, I like these sorts of games... ever since Spindizzy and Bobby Bearing on the ZX Spectrum, they can get really challenging.
The code is dark and full of errors

Attachments

Login to view attachments
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Jul 2016 18:29
for some reason my sphere totally vanishes, too out the ready condition

So I have this



that is called from this function:





as you see the line I have not indented!

yet immediately the sphere vanishes
if i rem out the line
SetObject3DPhysicslinearVelocity(player,sx2#,sy2#,sz2#,spd#)

it is of course there but cant move!


Hail to the king, baby!
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jul 2016 19:19
That is odd. One thing I would try, move the Step3DPhysicsWorld() to beneath the Repeat, so it gets called before player control... I know that doesn't make much sense, surely we should update physics after making the adjustments, then sync - but that's how it is in my test, and I can't remember why... it may well have been similar issues.
The code is dark and full of errors
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Jul 2016 19:36 Edited at: 12th Jul 2016 20:54
YES! that worked, I knew there was some oddity in some other post I had made, weird. I guess it needs to be called before any adjustments and before the sync()! So simply at the top of the loop indeed.
Thanks for your help.
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 12th Jul 2016 23:36
Under the documentation for the Step3DPhysicsWorld command it does state:

Call before the Sync() command at the bottom of the loop.

However this aint entirely true!
Hail to the king, baby!

Login to post a reply

Server time is: 2024-09-29 15:22:08
Your offset time is: 2024-09-29 15:22:08