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 / Colision Camera?

Author
Message
Yuhe
1
Years of Service
User Offline
Joined: 27th Aug 2017
Location:
Posted: 2nd Sep 2017 20:35

Any suggestions for a camera that follows the player in the third person to collide with the terrain and other objects?
janbo
10
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 2nd Sep 2017 21:16 Edited at: 2nd Sep 2017 21:16
Ah I saw your thread in the showcase section.
You could cast a ray from the player to the camera direction and get the length from the ray contact.
Then you set the new camera position to the ray contact position.
You can get the raycast contact position with Get3DPhysicsRayCastContactPosition

Feel free to ask more questions about it
Yuhe
1
Years of Service
User Offline
Joined: 27th Aug 2017
Location:
Posted: 2nd Sep 2017 21:45




Hi, thank you for your answer, I am a novice in this and I tell you that the camera in third person, I believe it having a central pivot that is father of another pivot in which I position the camera. I was hoping to set up a collider for the object child of the player's pivot, but it didn't work, you have some code example to understand the ray?, or in that case a simple drawing scheme, this would help a lot.

greetings.
janbo
10
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 2nd Sep 2017 23:45 Edited at: 3rd Sep 2017 02:08
Here you go !
Rick Nasher
1
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 3rd Sep 2017 14:27 Edited at: 3rd Sep 2017 14:29
Now that's a real nice one Janbo, thanks for sharing! I hope you don't mind I use this code too?

AGK takes a bit of getting used to.
The cam collision fix was actually going to be my next step in an universal switchable 1st/3rd person cam routine I'm working on.

Currently struggling a bit to have the cam/player respond correctly to transitions between terrain from a heightmap, using:
newy#=GetObjectHeightMapHeight(TerrainObjectID,newx#,newz#)
and other objects such as moving platforms/other players, using:
newy#=GetObjectRayCastSlideY(0)
but I'm not sure this is the proper way, will have to see.

Grtz & thnkz,

Rick Nasher
*ex-Blitzer*
janbo
10
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 3rd Sep 2017 15:02
Quote: "Now that's a real nice one Janbo"

Thanks and please use the code
So you are using RayCastSlide to manage the terrain collision ?
You could also calculate the terrain slope yourself or use the 3D Physics character controller...
Anyway to properly help you I/we need more infos, so if you feel you don't make progress, please make a new post and I'll be happy to help where I can.
Yuhe
1
Years of Service
User Offline
Joined: 27th Aug 2017
Location:
Posted: 4th Sep 2017 22:59



I am trying to implement this in the camera collision, I do not know if it is the best method, the end is not a game is a learning project and so far I am understanding the rays. The case is that it works and the camera collides with objects on the left-hand axis, facing the rear, but still in the tube the camera sinks.
Yuhe
1
Years of Service
User Offline
Joined: 27th Aug 2017
Location:
Posted: 5th Sep 2017 00:04
janbo
10
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 5th Sep 2017 01:35
Besides you forgot to change the y parameter of the new camera position in the code you posted above.
SetCameraPosition(1, GetObjectRayCastSlideX(0), GetObjectRayCastSlideY(0)
I'm not sure what the picture is about ?
If you want the ray to react earlier you could probably make a sphere cast instead of a normal one.
Yuhe
1
Years of Service
User Offline
Joined: 27th Aug 2017
Location:
Posted: 5th Sep 2017 01:56


I have this code, but the camera's sinking into the ground.
Rick Nasher
1
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 5th Sep 2017 20:35
Sorry Janbo slow reply:

Quote: "So you are using RayCastSlide to manage the terrain collision ?
You could also calculate the terrain slope yourself or use the 3D Physics character controller..."


No, for terrain I'm using GetObjectHeightMapHeight(TerrainObjectID,newx#,newz#).
And for the other objects like stairs, platforms, other players, that are below the players feet I'm using GetObjectRayCastSlideY(0).

But I'm first gonna try some stuff and if I can't get out of it I'll post it, thanks. (If worth while I'll post the resulting code anyway, so people don't need to re-invent the wheel ).






Rick Nasher
1
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 20th Sep 2017 22:44 Edited at: 21st Sep 2017 13:44
Just posting what I have so far, is still a work in progress(feel to comment/change/adjust/improve)..

[EDIT: While debugging I've just realized there's a whoooole lot of Bltz3D way of thinking nonsense in there, so corrected and of course collisions do ok now.]
Universal 1st/3rd Person Framework V4.2(updated)

Login to post a reply

Server time is: 2019-06-25 03:08:58
Your offset time is: 2019-06-25 03:08:58