To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Games

Reply
 
Thread Tools Search this Thread Display Modes
Old 02-19-2007, 10:14 AM   #1
Spu_uk
Junior Member
 
Join Date: Dec 2001
Posts: 10
Help with towing a trailer

Hi guys...

Hope you can help me figure out something that's driving me nuts!

Currently working on a little game that involves lorries/trucks. I've got near enough everything sorted except for one thing...getting the lorry cab to pull the trailer. How on earth do I do that??? The trailer needs to follow the cab around realistically pivoting at the trailer's rear wheels and the trailer/cab connection.

Can anyone point me in the right direction or, even better, give me a peek at the actionscript that would sort this out?

Thanks for your help!
Spu
__________________
Error 745a - Bad or Missing Keyboard, press F1 to continue
Spu_uk is offline   Reply With Quote
Old 02-19-2007, 11:09 AM   #2
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
wouldn´t that involve IK (inverse kinematic) ?
back in the days of GTA2 I remember some slobby implented attempt for doing that.


in any case it would mean that the trailer always points towards a spot of the truck (eihter the pivot itself or an offset pivot of that one). And with every move of the Truck the trailer would have to move with the truck within a constraint.
Is this even what you are searching for?
renderhjs is offline   Reply With Quote
Old 02-19-2007, 11:16 AM   #3
ChaseNYC
Flash Incompetent
 
ChaseNYC's Avatar
 
Join Date: Jun 2002
Location: new york city
Posts: 690
maybe this can help?
__________________
mmm signature
ChaseNYC is offline   Reply With Quote
Old 02-19-2007, 11:28 AM   #4
Spu_uk
Junior Member
 
Join Date: Dec 2001
Posts: 10
Yep, it's exactly what I'm after. To be honest I never knew anything about IK before your post but I've done a bit of reading on it now and it seems like the way I need to go. Thanks a lot!

Does anyone have any example code by any chance???

Thanks
__________________
Error 745a - Bad or Missing Keyboard, press F1 to continue
Spu_uk is offline   Reply With Quote
Old 02-19-2007, 11:30 AM   #5
Spu_uk
Junior Member
 
Join Date: Dec 2001
Posts: 10
ChaseNYC - Thanks for the reply. Yep, I'd seen that when I was searching around for an answer. Although that's what I wanted to achieve, it did actually say how to do it.
__________________
Error 745a - Bad or Missing Keyboard, press F1 to continue
Spu_uk is offline   Reply With Quote
Old 02-19-2007, 01:02 PM   #6
walnoot
Senior Member
 
walnoot's Avatar
 
Join Date: Apr 2005
Posts: 754
http://www.friendsofed.com/book.html?isbn=1590595181

check the sample chapter
__________________
game
walnoot is offline   Reply With Quote
Old 02-19-2007, 05:42 PM   #7
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
i had made something in class (due to boredom) that is similar to what you ask, not sure if it uses inverse kinetics though, i never read up on the topic
http://trogdorffe.tripod.com/attempted_optimization.swf
pardon me if its slow/poor looking, i made it kind of messy, and this is my attempted optimization

basically i find the dircetion one chain link is relative to another, and whilst keeping the same direction, set the distance to a constant
all the while, adding the _x and _y differences to the x and y speeds (later on during my boredom, I also distributed this energy between the two links evenly, to simulate action/reaction pairs, didnt seem to change much though)

virtual chain!! got a better looking one on my comp that has a bevel effect added
__________________
trogdor458 is offline   Reply With Quote
Old 02-19-2007, 05:56 PM   #8
Spu_uk
Junior Member
 
Join Date: Dec 2001
Posts: 10
Thanks for the links, Walnoot & trogdor458.

I've read through all of the info you guys have given me but *still* having trouble putting it into practice. It's the ability to control it with the keyboard rather than the mouse that's giving me grief.

I've attached what I've got so far but the movement is wrong. Keys UP & DOWN should make it go forward and backwards not increase/decrease the Y position. The same goes for LEFT & RIGHT keys.

Anyone get an ideas, please?

Thanks to everyone for your help!
Attached Files
File Type: fla Lorry_v3.fla (64.0 KB, 7 views)
__________________
Error 745a - Bad or Missing Keyboard, press F1 to continue
Spu_uk is offline   Reply With Quote
Old 02-19-2007, 06:05 PM   #9
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
you mean you want the car to move correctly? because that should be easy enough
__________________
trogdor458 is offline   Reply With Quote
Old 02-19-2007, 06:08 PM   #10
Spu_uk
Junior Member
 
Join Date: Dec 2001
Posts: 10
Yep, the car/cab to move like a normal car would and the trailer to follow. I've tried using the code I was using before I added the trailer that rotated the car but that then screwed up the movement of the trailer.
__________________
Error 745a - Bad or Missing Keyboard, press F1 to continue
Spu_uk is offline   Reply With Quote
Old 02-19-2007, 06:10 PM   #11
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
use this movement instead:

Quote:
if (Key.isDown(Key.LEFT)) {
ypos+=Math.sin((seg0._rotation-90)*Math.PI/180)*5;
xpos+=Math.cos((seg0._rotation-90)*Math.PI/180)*5;
}
if (Key.isDown(Key.RIGHT)) {
ypos+=Math.sin((seg0._rotation+90)*Math.PI/180)*5;
xpos+=Math.cos((seg0._rotation+90)*Math.PI/180)*5;
}
if (Key.isDown(Key.UP)) {
ypos+=Math.sin((seg0._rotation)*Math.PI/180)*5;
xpos+=Math.cos((seg0._rotation)*Math.PI/180)*5;
}
if (Key.isDown(Key.DOWN)) {
ypos+=Math.sin((seg0._rotation-180)*Math.PI/180)*5;
xpos+=Math.cos((seg0._rotation-180)*Math.PI/180)*5;
}
note how its not car movement, but it seems to be what you asked
__________________
trogdor458 is offline   Reply With Quote
Old 02-19-2007, 06:15 PM   #12
Spu_uk
Junior Member
 
Join Date: Dec 2001
Posts: 10
Thank you so much, mate! That's what I needed....I think.

Thanks again!
__________________
Error 745a - Bad or Missing Keyboard, press F1 to continue
Spu_uk is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Games

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:11 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.