Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: krane on January 31, 2017, 05:08:03 PM
-
I have a series of game objects that have been named with an integer (1, 2, 3, etc.)
I am getting the name of the object, and trying to store that as an integer.
But when I go to convert string to int, it doesn't work (see pic).
My steps are: Get owner (works correctly). Get name (works--stores name as string). Convert String to Int (doesn't work).
Is this something with the format of the string or some other problem? Or is it a bug?
-
This indeed looks (almost) right to me but because you've lined up all of those actions in one state, they not necessarily execute in the right order. You need to enable Action Sequence in order to process action-by-action in the state. In the top-right corner of that state window, there should be a dropdown menu and you can enable it there (gear icon).
Let me know if that works for you
-
No, that didn't solve the problem, and even breaking the actions up into different states didn't work either.
:(
-
the same sequence works for me
if, just for testing, you swap the current int variable for a fresh one, does it work?
-
Now that's very strange... Just to be sure, try separating them into different states and between each state add a state with Next frame action and enable debugging and open up FSM Log.
-
Nope, neither of these solutions work. Log shows no errors.
I'm attaching a package file to show the problem.
-
(bump) Nobody?
-
Did you try converting the String to some other data type, then from that data type to Int? Trying to see if there's something wrong with the action itself.
-
There is no action for converting a string to another data type.
-
You can do it in code. I'll check it out later.
-
There are a bunch on the ecosystem, to float, to bool etc.
If you don't use it yet, I can highly recommend it:
https://hutonggames.fogbugz.com/default.asp?W1181
-
Yeah, i just found to float
https://github.com/jeanfabre/PlayMakerCustomActions_U4/blob/master/Assets/PlayMaker%20Custom%20Actions/Convert/ConvertStringToFloat.cs
-
OK, it works when I convert it to a float, and then convert to an INT (but ONLY if I round up).
Still seems to be a bug. I'm going to report in bug reports.
-
It it doesn't work when rounded down or nearest, you should submit that too :)
-
Hi,
I downloaded your test package:
-- why did you implemented a next frame event every other state? to get a GameObject name, convert it to int and do an operation on this can be done in one state or a series of states without any frame delay.
-- ConvertStringToInt works converting "1" to 1 properly. I don't see where you have issues with this other than in your logic since you straight away substract -1 to that conversion leading to 0 in your case. Can you confirm you are aware of this?
If you have trouble with an action, do a scene with nothing but a start state and the action in it, so for example use ConvertStringToInt simply
So in your case I think it's simply the substraction by -1 at the end that you should remove. Else let me know, we'll investigate further.
Bye,
Jean
-
I added the next frame at the recommendation of people upthread
The -1 was because I was storing the items in an array, and the array starts at 0 whereas my scene #s start at 1. So, I subtract one to get the array number. But the problem is that it's the being stored in the array as -1, not as 0.
-
stop the whole game logic right at the convert string to int and see if its doing a proper conversion
if it is, than the problem is somewhere else
note that the variable value you see is the current one, not the resulting one from the operation