playMaker

Author Topic: Translate object to target with choosing axis  (Read 3520 times)

Kubold

  • Full Member
  • ***
  • Posts: 112
Translate object to target with choosing axis
« on: July 08, 2012, 02:16:14 PM »
I would gladly see something like Move to Target, but you should be able to pick certain axis. Right now you can only turn off vertical i think.
It should work like this script:

transform.position.z = Mathf.Lerp(transform.position.z, target.position.z, 0.5);
transform.position.y = Mathf.Lerp(transform.position.y, target.position.y, 0.5);

Basic use would be doing a camera follow a character in 2D sidescroller for example, but only in certain axis, with slight delay, without rotation.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Translate object to target with choosing axis
« Reply #1 on: July 08, 2012, 03:42:15 PM »
Good idea. I'll look into the best way to add more control there...

In the meantime, you could use a Set Position action with Late Update checked to clamp certain axis of motion. Or you could combine lower level actions for more control. See attached screenshots.

It helps to think of actions as modular components that can be combined to get exactly the behavior you want



Kubold

  • Full Member
  • ***
  • Posts: 112
Re: Translate object to target with choosing axis
« Reply #2 on: July 09, 2012, 05:00:48 AM »
Awesome!!! Thanks a lot for fast reply!

Kubold

  • Full Member
  • ***
  • Posts: 112
Re: Translate object to target with choosing axis
« Reply #3 on: July 09, 2012, 05:10:51 AM »
First solution seems better for now, since Set Position gives a glitchy/flickering effect sometimes. It "teleports" the object instead of smoothly translating it (at least it looks that way).