[BUG] Timer change "random" attribute not working
ahiung
Member Posts: 36
Timer
Every: X seconds.........[x]Run to Completion
-Change Attribute something.something To random(min,max)
does anyone has the same problem?
Comments
Works fine for me.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
did you try the code like mine? the problem is in the Random(min,max) function.
This are the non-working one I've tried so far.
1. self.position.X random(1,100)
2. self.size.width random(1,100)
3. self.rotation random(1,100)
4. self.bounciness random(1,10)
5. self.alternativeinstance random(any numbers)
my test are 100% accurate since I set timer change every 0.5 secs, but it stay the same all the time. I even set up log debugger to make sure.
Upload a test project and I will take a look.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Yes, either upload your project or screenshots.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
snk.to/f-cdpmwphv
ok, here you go, the file.
I'm very sorry bout for giving you guys hard time to find out the problem.
Okay, so there are two project files there. I narrowed it down to tw_ground but the only random function I see is in the randomspeedo actor where it says Every 0.5 seconds change attribute game.New attribute to random(1,4).
So... where exactly would I find the problem you're having? In which actor and in which rule/behavior? And if it is in fact game.New attribute, what is the purpose of that attribute and which actors (and where) use it?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
You must of changed the files since @tatiang looked at it and I did. A few things stand out
there are no random() functions and no save table actions. You should save a table each time you write to it.
Also your statement max(tableCellValue( game.Score ,1,1),tableCellValue( game.Score ,2,1),tableCellValue( game.Score ,3,1),tableCellValue( game.Score ,4,1),tableCellValue( game.Score ,5,1)) has to many parameters you can only have two.
See Definitions page for info on the max() function http://forums.gamesalad.com/discussion/69280/old-cookbook-definitions-page#latest
I don't know what it is you are after.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
I'm so sorry.
The file I want to fix is tw_ground.
I'm focusing on the actor "enemy1", the black thing which has no graphic implemented on it.
my Intention was to set random movement in X direction for enemy1 (either -100 to 100), just like patrolling the area.
since putting up Change Velocity will screwing up the movement to Y direction, I created enemySpeed Attribute integer attribute to determine what velocity the enemy1 should use.
I set up timer with change attribute function which will change the number of [enemySpeed] to random(1,3) and setting up rule when enemySpeed changed to 1, change attribute velocity X to -100, etc.
Well, since I failed to make it work, I simply test it from very basic instruction.
you will find Timer 0.5 sec with set self.Physics.Bounciness to random(1,10) along with rule printing log debug to the screen for everytime character bump the enemy1
so, when you run preview with debugger on, you will see log like this everytime you bump the enemy1.
Log(Actor: enemy1): 0
Log(Actor: enemy1): 0
Log(Actor: enemy1): 0
Log(Actor: enemy1): 0
Log(Actor: enemy1): 0
Log(Actor: enemy1): 0
Log(Actor: enemy1): 0
@colander : I'm sorry but I haven't touch anything about table yet, cause I don't know anything about it. So, all I use right now only basic logic.
The problem is that you typed a mathematical function (random) into the text/number field of the Change Attribute behavior. You have to use the expression editor (the little 'e' symbol) to enter functions.
By the way, you don't need Run to Completion checked unless the timer is inside a Rule.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
oh, thank you very much @tatiang.
thank's for letting me know about Run to Completion, to be honest I don't know what it does either, I just following the tutorial from youtube.
What @tatiang said plus you can not change the Physics settings at runtime. I used the Change Velocity action in your project and attached it, see if that works for you.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Run to completion means that the timer will keep running even if the rule becomes false. For example, if you have a Timer inside a When Touch is Pressed rule, it will only trigger when the actor is clicked/tapped but as soon as you release the click/tap, it won't. With Run to Completion checked, it will continue to run.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User