0
$\begingroup$

REWRITTEN: Lets just say I have it where my animation plays when I press the space bar. How can I have it where the animation plays from start every time I press the space bar rather than continuing?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

Disable the continue option on the action actuator and put the script between the sensor and the action actuator :

  • when the sensor send a pulse the script will be triggered
  • if there is action being played on layer 0 the script will stop stop it
  • the script passes the pulse to the actuator

cont = bge.logic.getCurrentController()
own = cont.owner

if own.isPlayingAction(0):
    own.stopAction(0)
cont.activate("Action")
$\endgroup$
19
  • $\begingroup$ Can you explain how this works? $\endgroup$
    – blackhole
    Mar 25, 2015 at 1:11
  • $\begingroup$ Doesn't do what I asked. I need it where every time I press space it will play the action BUT when you press space and it is already in the action it will reset. $\endgroup$
    – blackhole
    Mar 25, 2015 at 1:21
  • $\begingroup$ do you mean reset it ( stop it ) or (stop it and start again ) ? $\endgroup$
    – Chebhou
    Mar 25, 2015 at 1:22
  • $\begingroup$ 1st time you press: start; 2nd time (if animation is still going on): stop and start again; 2nd time (if animation is done): start $\endgroup$
    – blackhole
    Mar 25, 2015 at 1:23
  • $\begingroup$ that's exactly what it does, did you try it ? $\endgroup$
    – Chebhou
    Mar 25, 2015 at 1:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .