playMaker

Author Topic: Bool problem on mouse pick event mouse down [SOLVED]  (Read 4902 times)

cedrico

  • Playmaker Newbie
  • *
  • Posts: 8
Bool problem on mouse pick event mouse down [SOLVED]
« on: October 20, 2014, 02:46:28 PM »
Hey there, i'm trying to make a simple mouse down switch between true and false, i always come into infinate loop problem!
What is a simple way to have:
a bool variable named switcher
state 1 switcher bool false by default, first mouse down> go to state 2 set switcher bool to true.
second mouse down go to state 1 set switcher bool to false.
I'm really having a hard time, which is crazy because i set up things with set tag, get child, send event, send message without any problem...but i don't get the bool logic.
THX for your help in advance!
« Last Edit: October 20, 2014, 07:09:57 PM by cedrico »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Bool problem on mouse pick event mouse down
« Reply #1 on: October 20, 2014, 03:45:37 PM »
Why not just use Get Mouse Button in one state?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

cedrico

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Bool problem on mouse pick event mouse down
« Reply #2 on: October 20, 2014, 04:04:48 PM »
Hey Lane, that was my first go, but this is too basic for me for i want to locate it on specific game objects, not just press the button anywhere on the scene and it will do. Sorry that's why i had a try with mouse pick event.
Any idea ?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Bool problem on mouse pick event mouse down
« Reply #3 on: October 20, 2014, 04:14:36 PM »
D'oh, right. On a Mouse pick.

So, whats really at stake here then? What is the purpose of the bool and mouse pick? Whats the goal?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

cedrico

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Bool problem on mouse pick event mouse down
« Reply #4 on: October 20, 2014, 04:39:51 PM »
I'm no programmer so an int switch or a bool or something else might do the trick, i just tried to have the same function (in that case the mouse pick event mouse down) to have two different actions on the same object. Does that make sense ?
I had a go with the bool first to experiment. I thought true/false would be enough to handle it for two different states.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Bool problem on mouse pick event mouse down
« Reply #5 on: October 20, 2014, 05:10:09 PM »
Hmm, I can't really understand what you're trying to do.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

cedrico

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Bool problem on mouse pick event mouse down
« Reply #6 on: October 20, 2014, 05:17:49 PM »
hum...ok let's say you have two colors and intensity states for a point light, you want a game object to switch the light between the two colors and intensities each time you click, it switches back and forth, how would you go about that ?
« Last Edit: October 20, 2014, 05:20:06 PM by cedrico »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Bool problem on mouse pick event mouse down
« Reply #7 on: October 20, 2014, 05:28:23 PM »
I would do it this way..

Put an FSM on the light with an event called "Switch" or something. The light should be on a layer for 'interactable things'.

In your mouse FSM (or whatever) use Mouse Pick and filter on the layer you have 'interactable things' on, store the Game Object as a 'picked' variable. Use a Game Object Is Null action every frame when the 'picked' variable is no long null fire an event and go into a second state.

In that second state do a Send Event and target the 'picked' game object variable, send your "Switch" event or whatever you called it. The event must have been set to Global if you use the basic Send Event action. If you used Send Event By Name you may simply type the name in, but it does not update here if you change the event on the light, thats the disadvantage.

I use this same process but I use a generic "Clicked" event among others and it allows me to generically put states on any object while as long as they are on the Interactive layer I can click them and get an event sent.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

cedrico

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Bool problem on mouse pick event mouse down
« Reply #8 on: October 20, 2014, 05:37:32 PM »
Hum, it doesn't seem i can store a point light in the gameobject variable, i'm stuck here.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Bool problem on mouse pick event mouse down
« Reply #9 on: October 20, 2014, 05:44:00 PM »
That's odd I'll look at that when I get home.. if you happen to have mouse pick issues do the following.

Add a collider to it. If it's somewhere conspicuous put it on a special layer and take it out of the collision matrix to avoid accidental collisions if necessary.
« Last Edit: October 20, 2014, 05:46:42 PM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Bool problem on mouse pick event mouse down
« Reply #10 on: October 20, 2014, 06:51:32 PM »
Hum, it doesn't seem i can store a point light in the gameobject variable, i'm stuck here.

It works, a Point Light is just a gameobject with a light component on it. Maybe you mean that Mouse Pick can't store that exact object? You aren't trying to store that in the editor, you have to get it at runtime and thats why you are identifying it with a Mouse Pick... Mouse Pick is just going to see that you clicked something and it needs to be put into that variable there.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

cedrico

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Bool problem on mouse pick event mouse down
« Reply #11 on: October 20, 2014, 07:07:27 PM »
All right Lane, thanks i'll give it a shot tomorrow morning, not exactly sure of what you mean though. BTW the mouse pick event works great, i only inserted a 0.01 wait action between the int switch and the set int value and now i don't have a 1000 loop alert in the console! and you can't really tell it is there