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 / object following the matrix altitudes and angles

Author
Message
nob
4
Years of Service
User Offline
Joined: 27th Dec 2019
Location: Reunion Island
Posted: 27th Dec 2019 11:27 Edited at: 27th Dec 2019 16:45
Hello all ! (english is not my native language)
I used Darkbasic a long time ago and now i try to use Agk Classic to code my old projects.
I have created a "matrix" from a pict, using the "CreateObjectFromHeightMap" command.
I have placed an object (vehicle) on this matrix and added code to move it.
I would like to move the object to follow the matrix
I added code to get the matrix height at object coordinates (GetObjectX,GetObjectZ) and the object follows the different altitudes when it moves.
Now I would like to set the object orientations (xyz) according to the tiles angles.
I didn't retrieved equivalent codes and commands in AGK.
I guess it's a common problem, so i need at least a direction to follow to dig in the command list and the best method to reach this goal.
Thanks.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 27th Dec 2019 19:45 Edited at: 27th Dec 2019 22:08
nob,

for similar, i first went at it by calculating rotation on the x and z axis manually, as you are asking about, and then decided to let the built-in physics do the work with something like this:



there's a lot of tweaking necessary to get things to "feel right" if you want to take it beyond the simple example above but i've stuck with the general premise while i've worked on THIS.

IE, you'll want to look at all of the 3d physics commands and find the right friction, dampening, resistance, etc, and i also do manually check contact points, etc., to find a more "realistic" balance.

you can find a quickly playable example HERE, as well. where that's intended as a winter-themed demo, i've let things slide around and provided a general "arcade" vibe vs any kind of "simulation".

otherwise, blink has taken the idea the furthest i've seen, producing THIS ~a year ago while offering the source code, as well.

point is: i'm suggesting that you let AppGameKit do as much of the work as it can for you instead of trying to manually "do everything".

i hope this helps. good luck!

*correction made to linear velocity
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 28th Dec 2019 12:23 Edited at: 28th Dec 2019 12:24
Pseudocode:

One can also calculate the survace normal from 3 heights at different positions
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 28th Dec 2019 17:01 Edited at: 28th Dec 2019 17:19
blinks code worked well and enabled me to produce https://forum.thegamecreators.com/thread/223651
I particularly love the way even loop de loops were possible
but I see no reason why you cant make use of the charactercontrollers and simplify it allot like below


There was also a great example I forget who by (possibly santman) that had a car running over a terrain quite well

PS This is a very friendly forum so if you have difficulties and post an example people often love to help unlike other forums
MerryChristmas Everyone
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
nob
4
Years of Service
User Offline
Joined: 27th Dec 2019
Location: Reunion Island
Posted: 28th Dec 2019 19:38
Hello!
Thanks for your answers "Virtual Nomad" "janbo" & "fubarpk".
I just had time to experiment Virtual nomad solution for now, but i'll try the other code snipets you provided .
The good new is that i discover step by step "physics commands" and it seems to be an easy way to solve my problem.
But yet an other problem arises:
- my terrain size is 100x100 and the vehicle is small enough to fit in this environnement, so i must set down the "scale factor" of the "Create3DPhysicsWorld" command to "2" to get a realistic effect.
I think i must increase the size of the terrain to set the "scale factor" to "40" (default scale factor) to stay in an average value and avoid problems with future object using "physics, i'm right?
At this point, the pict (only one) used to texture the terrain will not give the same aspect. With DarkBasic I used to fill each tile with a part of a pict, randomly chosen. Allowing me to use a smaller pic file with seamless parts and get a natural effect on a large matrix.
Well, my new questions are:
whatever the method and code I'll use to fix my initial problem, should i first set the "Create3DPhysicsWorld" to default? and then, does AppGameKit, allows to fill tiles individualy?
Thanks
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Dec 2019 00:34 Edited at: 29th Dec 2019 00:36

Login to post a reply

Server time is: 2024-11-23 08:20:49
Your offset time is: 2024-11-23 08:20:49