playMaker

Author Topic: Some problems with MousePick[SOLVED]  (Read 2793 times)

NetGhost03

  • Playmaker Newbie
  • *
  • Posts: 4
Some problems with MousePick[SOLVED]
« on: September 08, 2013, 10:03:02 AM »
Hello everybody.
I've got some problems using mouse pick.

I am trying to do a click to move fsm,
I have an input state, with GetMouseButtonDown and MousePick which stores the data in a global targetDestination vector3 variable.

Then I am using iTween Move To, to move my character to targetDestination.

For a small area it works fine, but if I click on a building or far away, it bugs and my character starts to fly :/



Any idea how to fix this?
« Last Edit: September 09, 2013, 05:17:10 AM by jeanfabre »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Some problems with MousePick
« Reply #1 on: September 08, 2013, 12:34:28 PM »
When you click on the wall the targetDestination is in the air. So the character is doing what its told - moving to that point in the air!

You could use the Set Vector3 XYZ action to set the y destination coordinate to zero (or your ground height) to keep the character on the ground. Or use a character controller with gravity instead of iTween Move To. In the long run that's probably the better solution since it will allow your character to walk up and down stairs etc.

NetGhost03

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Some problems with MousePick
« Reply #2 on: September 09, 2013, 04:54:06 AM »
Thanks!

I thought it only works on the plane. Well actually it's only bugged in this scene.
I created a new scene with a plane and some buildings and it works without flying :d

NetGhost03

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Some problems with MousePick[SOLVED]
« Reply #3 on: September 09, 2013, 09:20:19 AM »
Okay I discovered the bug.
It's because of the coliders of the objects in the scene.
If I click on an object with a collider on it, it goes up in the air.
Can I somehow limit the mouse pick only to the ground plane?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Some problems with MousePick[SOLVED]
« Reply #4 on: September 09, 2013, 10:12:37 AM »
You can use Layers:
http://docs.unity3d.com/Documentation/Components/Layers.html

Create a NavTarget layer and use that on any object you want to be clickable.

Then in the Mouse Pick action, select Layer Mask and enter 1 (since you want to use 1 layer), then select NavTarget. This will restrict mouse picks to the NavTarget layer.

However, when I first saw your screenshots I assumed you would want the character to walk up to the wall if you clicked on it, not to some point on the ground beyond the wall... so you may want to still make the wall clickable and fix the target's y position...

johnflesh

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Some problems with MousePick
« Reply #5 on: October 07, 2013, 08:47:10 PM »
When you click on the wall the targetDestination is in the air. So the character is doing what its told - moving to that point in the air!

You could use the Set Vector3 XYZ action to set the y destination coordinate to zero (or your ground height) to keep the character on the ground. Or use a character controller with gravity instead of iTween Move To. In the long run that's probably the better solution since it will allow your character to walk up and down stairs etc.

To the bolded, how do you do that exactly? If I add a Character Controller and Rigid Body to the character I get some very interesting results in movements, primarily either rotating around the click point wildly or flying off into space.

I got the click to move to work okay on a flat plane but as soon as I drop it on a terrain with any height to it, it either floats from A to B or acts pretty nutty with gravity added via RigidBody.

Any hints for a newbie?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Some problems with MousePick[SOLVED]
« Reply #6 on: October 08, 2013, 03:01:00 AM »
Hi,

 To limit mousepick on a defined plane use this:

http://hutonggames.com/playmakerforum/index.php?topic=272.msg1087#msg1087

simply don't use the drag feature of it, but just the abilitiy to define a plane for the mouse pick.

bye,

 Jean