playMaker

Author Topic: Driving a car on aniTween Path  (Read 3532 times)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Driving a car on aniTween Path
« on: October 30, 2012, 06:32:23 PM »
I'm trying to get a bus to drive down a bumpy road... its just animation, no clever vehicle rigs needed.
I thought it would be a breeze to set up a iTween Path and use a moveto and Lookat.
Yes Im using your iTween Move To V2 Jean...

Its sliding along the road ok, but sideways, and spinning all over the place at corners. I feel like I need to somehow restrict the bus movement to XZ and somehow get gravity to set the bus down on the road. Adding rigid bodies and collidors half do it, but I just dont know the right combo...

Any hints?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Driving a car on aniTween Path
« Reply #1 on: October 31, 2012, 01:23:18 AM »
Hi,

 ok the key here would be to add a layer in between the object that is constrained to the path and your vehicle.

have a dummy to follow the path, then have your vehicle following the position of the dummy ( using get position/set position dance between the dummy and the vehicle every frame)

then your vehicle will not spin. To have your vehicle follow terrain if really bumpy, you might then want to raycast from the vehicle onto the ground, get the hit point normal and use that as a base for your vehicle to look at, so it will follow the path properly yet conform to the terrain bumpiness.

bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Driving a car on aniTween Path
« Reply #2 on: November 02, 2012, 08:12:22 PM »
Thanks for the reply Jean

the key here would be to add a layer in between the object that is constrained to the path and your vehicle.

Can you elaborate on this, what do you mean by a layer? I have NO object constrained to the path. I have the iTween Move To V2 placed on the bus itself, so I use Game Object= Use Owner  and the path set to the name of my iTweenPath... BusPath actually...  I have Move to Path ON.

Then you went on...

Quote
have a dummy to follow the path, then have your vehicle following the position of the dummy ( using get position/set position dance between the dummy and the vehicle every frame)
then your vehicle will not spin.

OK, Havent tried this yet, think I understand... maybe.. but can you explain why this would work, Im not getting it really.. Id like to understand as well as just follow orders!!

Quote
To have your vehicle follow terrain if really bumpy, you might then want to raycast from the vehicle onto the ground, get the hit point normal and use that as a base for your vehicle to look at, so it will follow the path properly yet conform to the terrain bumpiness.

Can I do this with playMaker? Point me to the right action if you will?

Actually I'm quite surprised this was so tricky. I would have thought that this technique would be exactly the same as animating an NPC around in a animation or cut scene. In fact thats soon my next job, having a character walk around on paths..., the bus is a bit of a test...

Anyway. Heres a little film of the issue,  I think you understood my predicament so this is just for fun really...

https://www.dropbox.com/s/phzpg4v1ysxgf3s/busslide.mov

Thanks in advance!

Mark
« Last Edit: November 02, 2012, 08:16:00 PM by markfrancombe »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Driving a car on aniTween Path
« Reply #3 on: November 05, 2012, 01:31:20 AM »
Hi,

 by layer, I mean that you create an empty gameObject called "pathFollower" or something. this "pathFollower" is controlled by iTween to move along the path.

then, every frame you get it's position, and set the bus position to that position. Then you can manually control the rotation and even alter the position if wanted.

as for raycasting: have a look at this:

http://hutonggames.com/playmakerforum/index.php?topic=900.0

With this, you can keep the bus on the ground properly.


bye,

 Jean