Repeat not working with Periodic function?

fanstudio

  • Posts: 201
Am I doing something wrong or these two should not work together (see the screenshot attached)?

mikefish

  • Posts: 18
I think you don't need the 'repeat until'.  If you put the 'do every' block inside a repeat then it will keep restarting/adding a new repeater.

See attached example.

Don't just drop that in an always though, because that will give you the same problem.  This block would need to be activated just once.

fanstudio

  • Posts: 201
It's working now :)

Thank you very much for your reply!

fanstudio

  • Posts: 201
Actually is not working as I expected... I am trying to "fade in/out" the movement of the train - to slow down and to speed up. Is there another way I can achieve this?

mikefish

  • Posts: 18
You mean when you stop you want it to slowly stop instead of immediately stopping? Have you tried tweaking the built in physics and friction?

Jon

  • *
  • Posts: 17533
If you don't mind the physics being overriden, what I think you're trying to do is tween the motion? The slide block under Actor > Tweening does that.

fanstudio

  • Posts: 201
@mikefish I'm not using gravity. yes, I don't want want it to stop immediately, just want it to slowly stop.

@Jon I will try the tweening today, sorry for the dumb questions but everything is new for me here :)

LATER EDIT:

The tweening function still doesn't let me achieve what I need, I have to think of something else...

« Last Edit: August 13, 2011, 08:24:59 am by fanstudio »

Jon

  • *
  • Posts: 17533
Perhaps if you let us know a little bit more about what you're trying to achieve, that would help Rhys or even a non-iStencyl specialist help you out.

fanstudio

  • Posts: 201
I have a car/train that is going across the screen at a certain Y speed. When I change the traffic lights to RED I want it to slowly stop (duration 1 sec).
I thought to use Repeat until Y self speed = 0 do Every 0.3 seconds increment Y speed to +1 but these functions are not working together...

Is there any other way to fade/interpolate the movement of an actor?

Jon

  • *
  • Posts: 17533
if(slowingDown)
set y-speed to (get-y-speed - (original-y-speed/100))

(The 100 part is basically derived from each frame of the game being 10 milliseconds, so we want to decrement by a hundredth of the original speed each time.)

There are better ways to do this, but that's the first to come to mind.

Repeat isn't what you're after. It's good for repeating a lot of things within the same frame, but it's not intended to be used across different frames.