playMaker

Author Topic: Touch object event and look at problem[Solved]  (Read 6427 times)

Vink

  • Playmaker Newbie
  • *
  • Posts: 19
Touch object event and look at problem[Solved]
« on: November 04, 2013, 12:45:28 AM »
Hello

Im having trouble setting up an touch object event, my goal is when i touch the object it looks at the opposite direction of the finger, but when i set up playmaker on it thru touch object event nothing happens but if i use a normal touch event it moves a little and then freezes at a certain rotation.

What i tried so far:
Touch object event ------- get touch info (getting finger position x,y)
 or touch event                screen to world point (convert it a world vector x,y)
                                      Look at (not much to explain here)

i tried to get that working before moving on, but it doesnt seem to respond to touch object, the object is child to a empty object with a hitbox and the fsm is on the empty game object
im using bluestacks to test all this and have been trying to fix this for about 2 days on and off now and went thru the ios fundamentals, i dont know anything about programming but manage to be able to use playmaker for a lot of tasks. I thank you in advance for your help
« Last Edit: November 05, 2013, 01:40:35 AM by Vink »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Touch object event and look at problem
« Reply #1 on: November 04, 2013, 02:01:52 AM »
Hi,

 do you mean you want the object you touch to look in the world ( in the same direction as the camera)?

simply use the z direction of the camera for the look at, using the action "Transform direction" with x=0,y0,z=1

If you still have problems, let me know,

bye,

 Jean

Vink

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Touch object event and look at problem
« Reply #2 on: November 04, 2013, 02:20:01 AM »
Ill give it a try and ill get back to this post to let you know, ill upload a pic so people might understand what im talking about

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Touch object event and look at problem
« Reply #3 on: November 04, 2013, 04:55:34 AM »
Hi,

 Have a look at this sample, it's a mouse look system.

 within this, if you want your turret to look the opposite way, simply use this setup but hide that pointing canon and attached your own canon the opposite way ( rotate it 180).

Bye,

 Jean
« Last Edit: November 05, 2013, 02:10:17 AM by jeanfabre »

Vink

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Touch object event and look at problem
« Reply #4 on: November 04, 2013, 06:39:32 AM »
Ok here is what I've been trying, in the first state is a "Touch object event" storing the finger.
a friend of mine wrote me this script that worked perfectly and i tried getting the same effect in playmaker with no luck:

using UnityEngine;
using System.Collections;

public class PointAtFinger : MonoBehaviour {
   Vector3 realWorldPos;
   Vector3 fingerPos;
   // Use this for initialization
   void Start () {
   
   }
   // Update is called once per frame
   void Update () {
      #if UNITY_EDITOR
      fingerPos =  Input.mousePosition; //for mouse
      #else
      fingerPos =  Input.GetTouch(0).position; //for touch screen
      #endif
      Vector3 pos = fingerPos;
      pos.z = 8;
      realWorldPos = Camera.main.ScreenToWorldPoint(pos);
      realWorldPos.z=transform.position.z;
      transform.LookAt(realWorldPos,transform.up);
      //transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x,0,0);
   }
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Touch object event and look at problem
« Reply #5 on: November 04, 2013, 07:42:50 AM »
Hi,

 what's not working with the sample I provided?

bye,

 Jean

Vink

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Touch object event and look at problem
« Reply #6 on: November 04, 2013, 09:37:05 AM »
Hi JeanFabre

I think i got it now, but "Touch Object Event" isnt working, once i sort it out ill update this post

in your sample i had a problem with a missing action "getmouseposition" i just replaced it with "get mouse x,y" might've been a rename or a custom scrypt

Thanks for your help so far, and your patience with a noob like me :)

Vink

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Touch object event and look at problem
« Reply #7 on: November 04, 2013, 10:16:06 PM »
Hi Jean

After going thru your example and trying it out except using get touch info, it at least looked at the screen.

So from there i took out "get position" and "Float multiply" instead i used set "set Vector xyz" after "Screen to World" leaving xy and setting z to 0 that worked perfectly.

Now do you have any idea of how to stop the object from flipping every 180*?

Vink

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Touch object event and look at problem
« Reply #8 on: November 05, 2013, 01:39:49 AM »
Solved

just need give it an up vector in the "look at" action
rotated the child object (turret) under an empty game object so it faces the opposite direction of where my finger is.

Thanks for all your help Jean
here is the finished product :D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Touch object event and look at problem[Solved]
« Reply #9 on: November 05, 2013, 02:06:22 AM »
Hi,

Very good,

I'll update the package to include this custom missing custom action, sorry about that.

bye,

 Jean