playMaker

Author Topic: Need Help With Touchscreen Functionality[SOLVED]  (Read 2452 times)

stodorany

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Need Help With Touchscreen Functionality[SOLVED]
« on: September 17, 2013, 09:42:31 AM »
Hello playmaker Community,

I have two balls in my game.I attached colliders and rigid bodies to both balls.  I would like to be able to touch each ball and move it to hit the other ball. Currently i am able to move the ball but when i hover over the other ball it simply goes through the ball and doesn't move the ball. 

THis is my Fsm FLow

State 1 ( touch object event) > State 2 (Get Touch Info / screen to world point / set position)

Currently when i touch the ball and move the ball through the screen and end the touch by moving my finger from screen, the ball still remains selected and doesnt fall back to the ground. I Would like the ball to fall to the ground and also to be able to collide with the other ball when selected. I hope someone can help me.

« Last Edit: September 20, 2013, 12:10:19 AM by jeanfabre »

bizilux

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Need Help With Touchscreen Functionality
« Reply #1 on: September 17, 2013, 10:20:51 AM »
attach rigidbody and collider on them?   

oh didnt read that you already did that... well yes is kinematic has to be unchecked too...
« Last Edit: September 17, 2013, 10:25:11 AM by bizilux »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Need Help With Touchscreen Functionality
« Reply #2 on: September 17, 2013, 10:23:57 AM »
Do either have IsKinematic checked? Both have Mass set to not zero? Use Gravity on? Scale of scene non-astronomical? Wearing your lucky shirt?

Typically when using direct transform changes and mixing it with physics you can get some weird results. The transform will override the physics. Also, if two rigidbodies overlap (due to a forced position change) then they will freeze and not respond to physics input.

stodorany

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Need Help With Touchscreen Functionality
« Reply #3 on: September 17, 2013, 10:44:39 AM »
Do either have IsKinematic checked? Both have Mass set to not zero? Use Gravity on? Scale of scene non-astronomical? Wearing your lucky shirt?

Typically when using direct transform changes and mixing it with physics you can get some weird results. The transform will override the physics. Also, if two rigidbodies overlap (due to a forced position change) then they will freeze and not respond to physics input.

Thanks for the respose. I have is kinematic for both objects off. Both masses are set to 1. Both of the gravity is on. the scene is set to 1280 x 720 and also is the background plane. My lucky shirt is tucked away in my wardrobe. Should i wear it now? hehe. Lane, I agree with you that forced position change may be freezing the physics response. I would like to know how else i can give have this sort of touch screen functionality over my objects without manually overriding their physics if possible. I was wondering if we could use a raycast to check for collision or maybe we can use "collision event, wake All Rigid Bodies or use gravity" actions.

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Re: Need Help With Touchscreen Functionality
« Reply #4 on: September 17, 2013, 12:10:10 PM »
[EDIT: After testing, the following guess is completely wrong. Don't pay any attention to it.]

This is just a guess...

I'm looking at the code for SetPosition and it uses transform.position. I believe for Physics to be properly implemented during a move, rigidbody.position should be used instead.

This is kind of weird for the playMaker FSM because it runs on the Update() cycle, but it is suggested that the rigidbody.position be changed on the FixedUpdate() cycle.
« Last Edit: September 17, 2013, 02:08:21 PM by GarthSmith »

stodorany

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Need Help With Touchscreen Functionality
« Reply #5 on: September 17, 2013, 12:35:51 PM »
This is just a guess...

I'm looking at the code for SetPosition and it uses transform.position. I believe for Physics to be properly implemented during a move, rigidbody.position should be used instead.

This is kind of weird for the playMaker FSM because it runs on the Update() cycle, but it is suggested that the rigidbody.position be changed on the FixedUpdate() cycle.


Thanks Gary Smith for your input. I get the general idea. Ive had a look at the script. And i do see the transform.position. Since the rigid body is attached to the gameobject, doesnt it get moved along with the transform.position of the object? Have you had any success with rigidbody.position?

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Re: Need Help With Touchscreen Functionality
« Reply #6 on: September 17, 2013, 02:07:32 PM »
Hello!

Please ignore that. My guess is wrong. >.> I'm doing some tests now and I get collisions detected even if I use transform.position.

So what else could it be... does one of your colliders have "Is Trigger" checked?

stodorany

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Need Help With Touchscreen Functionality
« Reply #7 on: September 17, 2013, 02:19:30 PM »
Hello,

Can you please give me some details of what you have done or how you were able to achieve this.
Please give me a breakdown of your fsm also. this is mine

State 1 ( touch object event) > State 2 (Get Touch Info / screen to world point / set position)

Are you using the set position action?  All is triggers are set to off on my objects.

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Re: Need Help With Touchscreen Functionality
« Reply #8 on: September 17, 2013, 02:42:30 PM »
Maybe the Screen to World Point is setting one of the balls in front of or behind the other? I'm not too sure what the issue could be...

stodorany

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Need Help With Touchscreen Functionality
« Reply #9 on: September 17, 2013, 02:51:25 PM »
Maybe the Screen to World Point is setting one of the balls in front of or behind the other? I'm not too sure what the issue could be...

Were you able to drag one of the objects into collision with the other successfully?
My screen to world has Z axis disabled so i doubt it will be sent in front of the object.

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Re: Need Help With Touchscreen Functionality
« Reply #10 on: September 17, 2013, 04:29:37 PM »
Hello!!!

Okay, so I set up a similar project, I show the ball moving around, then I was having the same issue you were having!

In my case it was because the project I was working on, in the Physics Settings, the default layer didn't interact with the default layer. Thus there were no interactions between the two balls.

Maybe that's your problem?

stodorany

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Need Help With Touchscreen Functionality
« Reply #11 on: September 17, 2013, 05:03:40 PM »
Hello!!!

Okay, so I set up a similar project, I show the ball moving around, then I was having the same issue you were having!

In my case it was because the project I was working on, in the Physics Settings, the default layer didn't interact with the default layer. Thus there were no interactions between the two balls.

Maybe that's your problem?

Hey,

I have the Default/Default layer ticked in the layer collisions matrix. I actually have all layers ticked. Were you able to solve the issue?

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Re: Need Help With Touchscreen Functionality
« Reply #12 on: September 17, 2013, 05:18:33 PM »
I set up a similar playMaker FSM as you described and was able to get one ball to collide with the other. I think at this point you need to send a copy of your project for troubleshooting.

stodorany

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Need Help With Touchscreen Functionality
« Reply #13 on: September 18, 2013, 06:07:45 AM »
Ok it seems my issue has been solved. There was sort of a bug between uni2d and playmaker. But after closing the project, reimporting both assets all seems to be going well. Thanks to all posters for your support especially GarySmith for letting me know that everything worked well on his end and this was not a playmaker problem.