playMaker

Author Topic: Change Int value when I click object with mouse  (Read 1626 times)

ingumak

  • Playmaker Newbie
  • *
  • Posts: 20
Change Int value when I click object with mouse
« on: September 15, 2017, 06:30:23 AM »
Hi!

This is a very simple question (I think). But I am not abble to get this. Simply I want to change an int value when I click down with the mouse on different objects. Each object has an assigned value.

I know do this with "Mouse Pick event" and create a different event for set int value. But it is an awful solution. I think  (I´m sure) that will be a best and more elegant way. I think it should work with a variable that save the value of the object I have selected and then, with a switch, send to the corresponding state.

But I don´t know how to do this with the actions. But I think it will be simple. Isn´t it?

Thanks!!!

ingumak

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Change Int value when I click object with mouse
« Reply #1 on: September 15, 2017, 07:16:26 AM »
Ok... I have found anothe way to do this.

Now I put a "Mouse Down" global Event on each of clickable objects to assigne the value for the global variable. And then, from my controler, I am controling the next actions.

This way I think, will force me to do a lot of "int switches" and events. Fewer than the first way. But I´m sure it is not the better solution. If anybody have an idea or any opinion or solution, it is welcome! :D

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Change Int value when I click object with mouse
« Reply #2 on: September 15, 2017, 01:38:50 PM »
Hi,
Actually i think mouse pick can be a good way to go especially if you have many objects.

after using mouse pick event
You can use layer(similar to tags) to pick only items with that layer.
Then you can use Get/Set Fsm actions to get or change the values.

Maybe you can give some more information about what you are doing or trying to achieve :)

ingumak

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Change Int value when I click object with mouse
« Reply #3 on: September 16, 2017, 02:49:43 AM »
Hi!

Thanks for the reply. Really I have achieved that I wanted. But i think it is not the best way.

Simply I want to save a number in a variable when I click with the mouse on one object. Each object have its value. And when I click down on one of them I want to get its value.

Then I want to use this value to know which of the object have been selected. And once knowed this, continue with the appropiate actions.

Thank you!! :D

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Change Int value when I click object with mouse
« Reply #4 on: September 16, 2017, 07:50:30 AM »
Hi,
If you have many object with on mouse down things can start to lag

that's why mouse pick would be better to use,

once you have picked the object, use "get fsm int" on the object to get its value.

or

you can use an array and place all the object in there, then after object picked do "array contains" and get the index nr and you could use that number.