1
$\begingroup$

I am working on my Boss character for a project in the Blender Game Engine. He has an attack animation that plays when he gets within range of the player (detected via a near sensor.) However, I would like the attack animation on the boss to stop playing and return to the first frame if the player exits the near sensor's range. Is this possible to do with logic bricks, and if so, how?

(Sorry if I´m doing this wrong) enter image description here I did this because I could not get the Near Sensor to work. (I replaced it with a Message, (called the "stop" where "Not Near" was and "Start" where the "Near" was) And so I add 2 new Property one with -1 frame if Start was False. and one with if frame# was less 0 then Assing 1. so it was always 1 if it gos back to zero. and added to a sensor where the boss is. So if I leave the area then it send the stop message and then Boss goes back to the starting position.

The only problem now is that if I leave the area and if the Boss is on Frame 30 And I go back then he starts on frame 1. But I will solve it.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

Yes. You can do this with logic bricks. You can actually do quite a bit with logic bricks. (I've made entire games only using logic just to prove it is possible to do so)

You'll need to start with two properties, a Boolean to control when the animation is playing, and an Integer property to control what frame the animation will display.

You'll need an always sensor (with true level triggering enabled) connected to an action actuator set to property - this will make the selected action display the frame of that action that correlates to the property that is set in the actuator.

You'll need your boss object's near sensors detecting the player, and assigning the Boolean property true or false.

Then, when the Boolean property is true, it will rapidly add 1 to the integer property controlling the animation's display frame, making the animation play. The moment the Boolean property turns false, it will assign the animation's frame to 1, resetting your boss object's attack.

You'll also want a property sensor waiting till the animation is done playing, to allow looping. to do this, set the value in that property sensor to however many frames is in your animation. When testing, I used a 40 frame animation, so I put 40 in that field. This property sensor can connect to the same actuator as before that assigned the frame number to 1, as it has the same function (resetting the animation.)

Or, if you do better with pictures:

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks to your help, I solved my problem. But not because of your solution. But I could not succeed without your help. What I wanted was to get the "Boss" to go back from the frame he was on and not going back straight to No. 1. eg 20, 19, 18 etc then 0 I don´t know how to add a Photo in a comment. So I edit my post and add the photo there. $\endgroup$ Oct 26, 2016 at 11:59
  • $\begingroup$ @RobinWillmann Well, I think your already doing something like this, but instead of just resetting the frame number, start subtracting from it until reaching 1, and then stop subtracting. $\endgroup$ Oct 26, 2016 at 17:19

You must log in to answer this question.

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