playMaker

Author Topic: Rotate Object to the Movement Direction of a different Object  (Read 5000 times)

aiya

  • Playmaker Newbie
  • *
  • Posts: 3
Rotate Object to the Movement Direction of a different Object
« on: January 12, 2014, 02:37:01 PM »
Hi awesome Playmakers,

I'm pretty new to Unity & Playmaker so your help is really appreciated! Maybe this Question is easy to answer but I can't get it right.

I have a moving/playable shopping cart and I am really happy with the gameplay so far. Now I want that the wheels of the shopping cart rotate to the direction of the shopping cart's movement. So the Z-Axis, for example, simply needs to face the direction. Since I use torque to move the cart around, so that it feels really nice, I am a bit clueless of how to get the direction.

I already tried to get the Position of the cart and store it into a Vector and then use this as the Target Direction for a "Smooth Look At Direction" Action on a wheel. But this doesn't really work out.

It doesn't have to be super-accurate or physical correct.. just perform a bit like a real shopping cart wheel would perform.

Thanks in advance! I'm really thankful for every little hint.
« Last Edit: January 12, 2014, 02:41:39 PM by aiya »
The truth is out there. Anybody got the URL?

MajorIdea

  • Full Member
  • ***
  • Posts: 131
Re: Rotate Object to the Movement Direction of a different Object
« Reply #1 on: January 12, 2014, 03:35:23 PM »
Hmm... maybe you could get and store the rotation values of the cart relative to the world every frame and set the rotation of the wheels to those values also every frame?

aiya

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Rotate Object to the Movement Direction of a different Object
« Reply #2 on: January 12, 2014, 04:14:40 PM »
Hi MajorIdea,

thanks for replying! That would be a nice little trick but sadly it doesn't work in that case (at least in my understanding (sorry if I'm wrong)) because the shopping cart can also roll sideways (not like cars which only roll forwards). So the wheels always stay in the direction of the cart.

What I want to achieve is that, for example, if the cart is moving sideways (still facing Z but moving on the X axis) that the wheels rotate to the direction of the movement.

The truth is out there. Anybody got the URL?

mikejkelley

  • Full Member
  • ***
  • Posts: 136
Re: Rotate Object to the Movement Direction of a different Object
« Reply #3 on: January 12, 2014, 10:05:33 PM »
The cart is playable, correct? You could have the wheels cue off input.

aiya

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Rotate Object to the Movement Direction of a different Object
« Reply #4 on: January 13, 2014, 05:59:48 AM »
The cart is playable, correct? You could have the wheels cue off input.

Hi Mike,
yes it's playable. I just torque to control it. What do you mean exactly with *cue off input*? Thanks in advance.
The truth is out there. Anybody got the URL?

mikejkelley

  • Full Member
  • ***
  • Posts: 136
Re: Rotate Object to the Movement Direction of a different Object
« Reply #5 on: January 14, 2014, 03:46:05 PM »
I think I missed the part about torque, is the input essentially coming from an accelerometer or something?

Quote
I already tried to get the Position of the cart and store it into a Vector and then use this as the Target Direction for a "Smooth Look At Direction" Action on a wheel.

You might want to get two positions and use the difference between them to determine the Target Direction.

Although your wheel movement would "lag" behind that of your cart.

You could do the reverse and have torque operate on the wheels (+ non-rendered mesh or smthg) and have the cart follow.

I could be really off base here though.


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Rotate Object to the Movement Direction of a different Object
« Reply #6 on: January 15, 2014, 08:28:03 AM »
I would use the player inputs to turn the wheels or else rig up the wheels like actual wheels and let the physics engine attempt to turn them properly but they would probably be much harder.

Get Axis Vector is probably what you're looking for.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D