playMaker

Author Topic: Follow another object  (Read 5971 times)

theBrandonWu

  • Playmaker Newbie
  • *
  • Posts: 18
    • Studio Pepwuper
Follow another object
« on: June 25, 2011, 01:06:32 AM »
I am sure this is simple but for some reason couldn't figure it out and always went back to writing a short script for it. How do I create a FSM so that an object would continuously follow another object? How would you create an FSM that needs to repeat actions continuously as in Update()?
Studio Pepwuper: http://www.pepwuper.com
One Month Game School (now on SkillShare): https://www.skillshare.com/r/user/thebrandonwu

tofusoup

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Follow another object
« Reply #1 on: June 26, 2011, 11:16:25 PM »
Isn't there a lookat action?  I'm not sure how your game is setup but you can lookat the object and translate it.

As for continuously loop most actions have per sec type setting, if not you can create a timer and when it's done it can call trigger your event again?

Not sure if this helps

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Follow another object
« Reply #2 on: June 27, 2011, 08:19:17 AM »
Hi,

 If you create a one state fsm, and inside it have your set of actions to follow a gameobject, it will run endlessly.

Here is something to try:

 Create a fsm on the object that need to follow another.
 On the start state, add a moveTowards action.
 In that MoveTowards action, set the target object to the game object you want to follow.

 This is sufficient to have the ball running. when you hit play, that fsm state will run continously and have its gameobject follow the target object defined in the MoveTowards action.

 If you can't get that to run, post a reply, and I'll make a working example.

Bye,

 Jean
 

theBrandonWu

  • Playmaker Newbie
  • *
  • Posts: 18
    • Studio Pepwuper
Re: Follow another object
« Reply #3 on: June 27, 2011, 11:55:33 AM »
I guess Follow isn't the right word here. What I want to do is for an object to mirror another object's position on two axes. For example, when I want to set the camera to move with an object on a 2D plane, there for I'd want to copy the x and y position of the object to the camera object but not the z position. Not sure if MoveToward can be used in this situation.
Studio Pepwuper: http://www.pepwuper.com
One Month Game School (now on SkillShare): https://www.skillshare.com/r/user/thebrandonwu

tofusoup

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Follow another object
« Reply #4 on: June 27, 2011, 01:31:55 PM »
How about using Clamp?  If the object has rigid bodies you can also constrain xyz in properties.


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Follow another object
« Reply #5 on: June 27, 2011, 01:34:09 PM »
Sounds like you should use Get Position and Set Position actions.

theBrandonWu

  • Playmaker Newbie
  • *
  • Posts: 18
    • Studio Pepwuper
Re: Follow another object
« Reply #6 on: June 27, 2011, 01:57:59 PM »
Set Position and Get Position with "Every Frame" checked would probably work. I'll look into clamp as well. Thanks guys!

For other actions (or a combination actions) that I want to be performed every frame, if they don't have the "Every Frame" check box, how should I have them executed every frame? Should I create a Finish event and have it point back to the same state? This seems to create an infinite loop and slows the game down to a crawl.
Studio Pepwuper: http://www.pepwuper.com
One Month Game School (now on SkillShare): https://www.skillshare.com/r/user/thebrandonwu

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Follow another object
« Reply #7 on: June 28, 2011, 05:12:01 AM »
Hi,

 some actions performs solely on everyframe because it's supposed to work like that, so when there is no such check box, it doesn't necessarily means it's only performing once on Enter. the "on every frame" is something totally left to the action author to implement.

 if you want to perform a series of actions, then it would a case by case problem really. split your behavior into several fsm, each performing something specific and continous, this might be the key to your problem.

Can you describe what you mean by "other actions"? then will be in a better position to propose solutions.

 Bye,

 Jean