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 / help needed. im stuck.

Author
Message
haliop_New
User Banned
Posted: 24th Nov 2016 07:49 Edited at: 24th Nov 2016 14:23
hi.


I'm building a 3d game where a spaceship is following a track.
the track is built from 3d objects connected to each other end.

so once the spaceship is on the track it casts a RAY (SetobjectRayCast) downwards and a bit forward on the z axis
the ray then catches the angles and positions of the ray touched id.

then I rotate the spaceship with those angles so if it goes up the spaceship goes up if it goes right the spaceship goes right.
I want to keep the spaceship on course at all times when the player can move right or left inside the track avoiding obstacles.
but every time I play it the spaceship runs off course.
the code (pseudo) looks something like that:



so in this way the spaceship should follow the track at all times but for some reason it doesn't
maybe there's another way to do the same thing I haven't thought of it yet.

hopefully someone will light my head with ideas

thank you for your time.
haliop.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Nov 2016 08:55
Not a very helpful thread title...
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 24th Nov 2016 10:55
can you provide a example here? code,cube,track
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS Sierra (10.12)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Nov 2016 11:13
This is the "normal" way to make tracks. First, make the track path from splines. You store the spline data of the track, and use this to position your vehicle.
This can still work with prefabricated track pieces, as long as you can make spline data from it.



I posted a lot of info and code here...

The Road to Nowhere
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
haliop_New
User Banned
Posted: 24th Nov 2016 12:09
yeah I fixed it sorry for the trouble
however Batvink I have a different problem now

when the track goes 180-360 somewhere in between the camera flips

so the game follows the track smoothly but camera flips if the angles are too high for both ways up and down
did you encountered that problem?

it works like this:

theres the primary spaceship model.
there a small box attached to it to use as camera positions.



so the game works find but the camera flips from time to time if the track is too swirly
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Nov 2016 14:03
Quote: "when the track goes 180-360 somewhere in between the camera flips "

That's the 'fun' aspect of using Euler or matrix rotations. To avoid the flipping you will need to use quaternions.
Good luck with that! They are not easy to understand!!
AGK V2 user - Tier 1 (mostly)
haliop_New
User Banned
Posted: 24th Nov 2016 14:18
this is what happens :



please help. what about Euler ?
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Nov 2016 14:45
It's called gimbal lock.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Nov 2016 15:13
And you avoid it with quaternions
AGK V2 user - Tier 1 (mostly)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Nov 2016 15:37
haliop_New
User Banned
Posted: 24th Nov 2016 16:46
so I guess its math time... :/
I rad a bit in seems very confusing
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 25th Nov 2016 03:30 Edited at: 25th Nov 2016 03:32
Check out this video on youtube...it explains what actually happens when a gimbal lock occurs

Gimbal Lock
haliop_New
User Banned
Posted: 25th Nov 2016 05:49
saw the video ... didn't really get it ...
have anyone did this already and mind sharing the code ?
I think this should be on the snippets code.
haliop_New
User Banned
Posted: 25th Nov 2016 06:09
I have found this on the DBP forum



but this didn't worked out still getting gimbel lock...

Login to post a reply

Server time is: 2024-04-19 21:00:12
Your offset time is: 2024-04-19 21:00:12