Oscillating motion using MOD
sparkzilla
Member Posts: 152
Hi I'm trying to use the MOD function to make a horizontal line come up from the bottom of the screen and then reverse direction when it hits 20 pixels. I've tried lots of combinations but no luck :-(
Spawn actor at position y=0 direction 90degrees (up)
Change attribute game.linetoggle =(self.position.Y)%20
When game.line toggle = 1
Change velocity direction 270degrees (down)
OTherwise
Change velocity direction 90degrees
RESULT: The line moves from the top of the screen to the bottom instead of from the bottom, up 20 and then back.
Does the initial change attribute need to be in a timer?
Spawn actor at position y=0 direction 90degrees (up)
Change attribute game.linetoggle =(self.position.Y)%20
When game.line toggle = 1
Change velocity direction 270degrees (down)
OTherwise
Change velocity direction 90degrees
RESULT: The line moves from the top of the screen to the bottom instead of from the bottom, up 20 and then back.
Does the initial change attribute need to be in a timer?
Comments
1) I realized that the actor should spawn at 0 degrees otherwise the orientation is wrong
2) no need for a timer
but I still cannot get it to go back and forward. Any ideas most appreciated