playMaker

Author Topic: Look At2 Not working properly  (Read 3529 times)

Pivetta

  • Playmaker Newbie
  • *
  • Posts: 16
Look At2 Not working properly
« on: January 21, 2016, 07:42:28 AM »
Hi, I need to use actually a lot this action in my game, I managed until now to use workarounds to it, but the Ecosystem variant of Look At2 is not working as it is meant to.

The local coordinates are not working on updates, they get scrambled and it looks weird. I built a little setup on the border of my scene to replicate the issue.
Yesterday I also updated playmaker and Unity, everything is running smooth but the issue is still there.
My knowledge of C# and the Unity api is to small to actually understand where the issue lays.

In the attached screenshots you can see the setup of the fsm the simple hierarchy, and actually how it works well when the parent object is not rotated and how it gets wrong when i rotate the parent.

I have hope!
Long life to playmaker!

Thanks in advance,
Pivetta

Pivetta

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Look At2 Not working properly
« Reply #1 on: January 21, 2016, 08:37:33 AM »
I don't really get this, but I feel It's pretty odd...

From Get Axis2:
Code: [Select]
if (keepVertical.Value)
            {
if (constraintLocally.Value)
{
lookAtPos = go.transform.InverseTransformPoint(lookAtPos);
lookAtPos.y = 0;
lookAtPos = go.transform.TransformPoint(lookAtPos);
}else{
lookAtPos.y = go.transform.position.y;
}
            }

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Look At2 Not working properly
« Reply #2 on: January 21, 2016, 10:05:38 AM »
Hi,

 Good catch.

 The code is not odd, it was actually even missing more oddities :)

 the upVector wasn't expressed locally so it was targetting properly, but it was missing a local version of the up vector.

Can you try to update the action from the Ecosystem and test?

Let me know how it goes.

 Bye,

 Jean

Pivetta

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Look At2 Not working properly
« Reply #3 on: January 21, 2016, 10:44:58 AM »
Thanks Jean,
But it's still not working...

I had an hard crash on updating (nevermind, my unity was since more days open) and then I rebuilt the sample I posted before as I didn't save (shame on me), the script is updated (I removed and readded the action), now I have

Code: [Select]
upVectorValue = go.transform.TransformPoint(upVector.Value);
to the constraint locally part.

but the result is still misleading
[picture in attachments]
I also putted in the parent object a fsm rotating it with "mouse look" to be sure it behaves in game environment and it's not because I'm rotating it in the editor.
but in both cases the rotation is wrong and glitches on the parent rotation update.

Thanks again for the quick support!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Look At2 Not working properly
« Reply #4 on: January 22, 2016, 12:49:44 AM »
Hi,

 ok, that's odd. it works here, so I made a sample you can download here for now.



Little gif animation

 If the sample works for you, then I'll push it on the Ecosystem, else let me know what is different in your setup, maybe I am not rigging the objects like you do and there is something to fix on a different level.

Bye,

 Jean
« Last Edit: January 22, 2016, 12:51:26 AM by jeanfabre »

Pivetta

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Look At2 Not working properly
« Reply #5 on: January 22, 2016, 07:39:59 AM »
I'm sorry bothering again, but actually it behaves really in a odd way as you say:

Your example works perfectly, then to test it out, I made a prefab out of your tank/turret/cannon object and imported it back in my scene.
I set the same target I was using for the other tank.
(I'm going to use the function for joystick angle and player look direction the tanks are easy for displaying the issue).
And it behaves again like the one I made on my own, pushing his Y up direction somewhere in an unprecise direction...
[picture in attachments]

I know my scene is an overkill of functions with 202 bool compares 19 raycasts and so on (the framerate is good tough), but I don't get why it behaves like this.

I'm using playmaker 1.7.8.3p2
In Unity 5.3.1f1

I'm terribly sorry for this riddle, If you mean I can PM you the whole project (with playmaker and the ecosystem functions it's around 80MB)

Cheers,
Pivetta

Pivetta

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Look At2 Not working properly
« Reply #6 on: January 22, 2016, 09:19:13 AM »
Ok, i still don't know why this is happening but a friend of mine made a look at3 version for me, where the upVectorValue is calculated with:

Code: [Select]
upVectorValue = go.transform.parent.up;
instead of:

Code: [Select]
upVectorValue = go.transform.TransformPoint(upVector.Value);

It's crunchy but at least it works!

Cheers,

Pivetta