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.

Newcomers AppGameKit Corner / Character not falling off box...

Author
Message
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 23rd Apr 2017 21:27
Hi,

In 2d physics I was able to get my character to hit walls, fall in holes, fall off the map, etc. But in 3D I am doing something wrong, and I don't know what.

I have created a box for the character to walk on. Its set to static, and the character is set to Dynamic. I have played with the gravity and mass, and I can get him to float up. But I can not get him to "fall" off the box. He just keeps walking along like he's Jesus, and rest assured he is not. Also, once I turned on Step3dPhysicsWorld he sunk into the box, and it looks like he is walking knee deep in dirt. So clearly something is going on.

Can someone help with solutions? He should be walking on top of the box.. not in it, and fall off the box when he walks off.



Here is the load characters code



Appreciate any help. I've attached two screenshots.

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: 24th Apr 2017 13:50
You can not move a dynamic object, that is done by the physics engine.
You need to use the character controller instead. Here is some examples.

https://forum.thegamecreators.com/thread/216683
The coffee is lovely dark and deep,and I have code to write before I sleep.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 24th Apr 2017 22:03
Gotcha. I didn't know that. In 2d I was able to move them with no problem, so I assumed the same thing.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 25th Apr 2017 00:39 Edited at: 25th Apr 2017 01:28
OK, I got it to work after fudging with some numbers. My character didn't need to be offset(he's really tiny). Very cool. It seems to be working. Thanks, Stab!!! I just need to fix my camera, because its bouncing all around now lol.

The z-axis on the camera is the culprit.

What would make the camera so jittery on the z axis? It was fine when I was using spherecast to move him along the terrain. Any ideas?


Thanks.
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: 25th Apr 2017 01:56
I saw your post before you edited it because I got it in an email.
It seems that you are mixing the 3D physics commands with the other basic collision commands.
For instance ObjectSphereSlide() does not work with the 3d Physics commands.
If you post your code I can see what you are doing wrong.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 25th Apr 2017 23:00
Yea, I didn't want to give up on the physics, so I tried again. Turned out, he was walking in the mesh, because I was using an offset that was unneeded.

No, I have the spherecast movement code remarked out.

Physics code that is causing the bouncey movement. If I lower the walk velocity it causes less of a bouncey movement

Here is the spherecast if you wanted to see why I can't test a hit on my "hero". But it works when I test the "ground".


Thank you, Stab.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 25th Apr 2017 23:15
And, of course, I remark out the physics when I was working with the spherecast.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 25th Apr 2017 23:51 Edited at: 25th Apr 2017 23:53
Nevermind, I remarked out the setcameralookat, and just added a manual offset in the camera position, and it fixed the issue.

This is awesome, Stab!!!!
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 27th Apr 2017 01:18 Edited at: 27th Apr 2017 01:20
Jerky movement. If I set the camera to stay the character doesn't bounce around. But if I set the camera to follow him its bouncing all over the damn place.



Pretty simple code.

SetCameraPosition(1, GetObjectX(game.player.objID),GetObjectY(game.player.objID)+12,GetObjectZ(game.player.objID)-25)



You may not be able to see the video as its on my facebook, but I included it as attachment.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 27th Apr 2017 02:09
use the y value from the ground plane
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 27th Apr 2017 23:06
blink0k, there is no change. Its the z-axis causing the bouncey , jerky movement. If I don't use the physics engine it doesn't bounce when he moves. So... I dunno... lol
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 27th Apr 2017 23:16
Hmmmmm, I have no idea what made me decide to do this. But in my slightly inebriated mind I thought I would try to put the camera position command after the physics command. I think I subconsciously understand, but certainly not smart enough to get it. IT WORKED!!!!


if Get3DPhysicsCharacterControllerExists( game.player.objID )
CharacterControllerInput( game.player.objID )
endif
//PrintC(GetObjectRayCastNormalX(0))
//movehero(game.player.objID)
Step3DPhysicsWorld()
cameramovement()
Sync()
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: 28th Apr 2017 00:47
Congratulations, you have now learned a very important programming rule.
Sometimes the order of the code matters.
Sorry, I should have suggested it.
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-22 03:23:24
Your offset time is: 2024-11-22 03:23:24