playMaker

Author Topic: How...do I make an object always track the first person controller? SOLVED!  (Read 4752 times)

ArloBarlow

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
So...I have some objects in a scene which I want always to look at my first person controller.

I've tried look at and look to and every variation of these, but the best result I've had is that the objects rotate to look at the original position of my FPC but don't track it as it moves.

Essentially I'm trying to create a static turret that only rotates to point at my FPC wherever it is in the world. It should always track the FPC.

I hope that makes sense. I'm a newbie to this stuff. Usually I find the solution on my own but this one has defeated me.

Thanks
« Last Edit: August 06, 2013, 12:16:47 PM by ArloBarlow »

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #1 on: August 04, 2013, 06:53:17 AM »
Hi,

You would definitely use the 'Look At' action for this. Make sure that the 'Target Object' is set to the player controller and leave the 'Target Position' as none. Make sure that the 'Every Frame' box is checked too because otherwise it wont update while you move. It might be worth you turning on the 'Draw Debug Line' too so that you can make sure the raycast is following your player.

Hope this helps!

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • View Profile
    • Pixel Life - portfolio
Re: How...do I make an object always track the first person controller?
« Reply #2 on: August 04, 2013, 12:53:29 PM »
This does indeed sound like it could be solved by simply checking the "every frame" option.

In case you are not familiar with it, the difference between having "every frame" on and off is simple.

With "every frame" OFF, the action in question will be performed ONCE and no more after that, unless you go back to the state again. This is most likely what is happening to you - when the turret enters the "look at player" state, it will get the players position and rotate to it ONCE and then just stay there doing nothing.

When "every frame" is ON, the action in question will perform in every frame, meaning constantly, and will not stop until you exit the state. This will make your turret constantly updating the players position, and rotating to it. If you are using the "finished" transitions, "every frame" also means that the transition will not be called, as the state never really finishes (because it will keep performing your action and never stop), so to move to another state, you could simply use a "send event" action, a "wait" action (if you want to go to another state after a ceartain amount of time) or use any other action like get distance or raycast to trigger transitions.

I hope this helps :) And welcome to playmaker!

-Koz
« Last Edit: August 04, 2013, 12:56:08 PM by KozTheBoss »
Remember, you don't fail unless you give up trying to succeed!

ArloBarlow

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #3 on: August 04, 2013, 01:57:24 PM »
Thanks guys.

It turned out that I had not dragged the first person controller from the Hierarchy into my project, so the boxes were looking at some notional coordinate...

So it's working fine now. The boxes track my FPC, but they track it a little too perfectly.

Trouble is I don't know how to control the speed. Look at doesn't have a speed control as far as I can see.

Any idea which action I need to plug in to slow the tracking down?

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #4 on: August 04, 2013, 02:30:36 PM »
There's another action called 'Smooth Look At' which would do exactly that, but it's a 'one shot' kind of action, so it doesn't have the 'every frame' checkbox....

What you could try, is to create a new invisible empty game object and have it smooth follow the player character. Then you have your 'Look At' action, look at the empty game object instead!

All you would need to do is create a new empty game object (GameObject > Create Empty), then use the 'Smooth Follow Action' action on it, making it follow the player. You'd need to play around with the settings, but I don't see why this wouldn't work...

Hope this helps!

ArloBarlow

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #5 on: August 04, 2013, 03:06:33 PM »
Thanks Vector...but it's still not what I need.

The boxes/turrets are still tracking the smooth follower at the same speed as the FPC.

I shall do some more internet trawling to see if I can find what I need.

mikewwayne

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #6 on: August 04, 2013, 05:22:10 PM »
ArloBarlow - is right look at does not work no matter how i set it up it does not work something is definitely wrong in playmaker 1.6.3  The Editor keep crashing. And it is very jittery during game play.

ArloBarlow

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #7 on: August 04, 2013, 06:29:11 PM »
Mike - mine is working but there's no way I can find to out a lag on the tracking. I want the turrets to have a maximum rotation speed when they're tracking. Right now they move as fast as the controller and that's not what I want, even though it's better than not moving at all (which was my original problem, of course)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14334
  • Official Playmaker Support
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #8 on: August 05, 2013, 02:54:46 AM »
Hi,

 you need to do the following:

 have an invisible turret that indeed points straight to the target, and have your actual turret smoothly catching up with that dummy.

does that make sense? you can use then action such as smooth look at direction.

bye,

 Jean

ArloBarlow

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #9 on: August 05, 2013, 10:59:10 AM »
Thanks Jeanfabre - I shall try that approach. I'll let you know how it goes.

ArloBarlow

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #10 on: August 05, 2013, 11:28:48 AM »
Hi,

 you need to do the following:

 have an invisible turret that indeed points straight to the target, and have your actual turret smoothly catching up with that dummy.

does that make sense? you can use then action such as smooth look at direction.

bye,

 Jean

I'm sorry to report that this has  the same problem as earlier suggestions - the turret does indeed rotate slowly to catch up with the dummy object but then it just stops after orienting itself with the dummy's starting orientation.

I've seen may videos on rotating turrets that do exactly what I want to do but they don't explain how to do it.

Maybe it's not possible with PlayMaker..? 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14334
  • Official Playmaker Support
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #11 on: August 06, 2013, 12:51:41 AM »
Hi,

 Actually, I overcomplicated it, there is an action ready for this: "Smooth look at". the catch in your case is to set the "finish tolerance" to 0, else it will stop monitoring if it finally catch up with the target.

Please find attached a working scene, showing a turret smoothly catching up with a target.


bye,

 Jean

ArloBarlow

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How...do I make an object always track the first person controller?
« Reply #12 on: August 06, 2013, 12:16:25 PM »

Wow.

So simple!

That's EXACTLY what I needed.

Thanks so much


Hi,

 Actually, I overcomplicated it, there is an action ready for this: "Smooth look at". the catch in your case is to set the "finish tolerance" to 0, else it will stop monitoring if it finally catch up with the target.

Please find attached a working scene, showing a turret smoothly catching up with a target.


bye,

 Jean