Need Help With Collisions On Specifc Frames

Game Editor comments and discussion.

Need Help With Collisions On Specifc Frames

Postby SuperNoob » Sat Sep 04, 2010 4:28 am

I've been checking the forums and documentation for a way to trigger events like collisions on a specific frame of animation, but so far, the only thing I have found that resembles this mechanism if the "wait for frame" box, but I can't figure out how to make it work. Is this what I should be trying to use for this purpose, or is there some other way to do the same thing?
SuperNoob
 
Posts: 12
Joined: Thu Aug 26, 2010 6:55 pm
Score: 0 Give a positive score

Re: Need Help With Collisions On Specifc Frames

Postby skydereign » Sat Sep 04, 2010 4:50 am

Well you can't have the event only triggered on specific frames, but in the collision event, you can check the animpos, frame number, and animindex, animation. So if you want the actor to change color when colliding with the ground, on the 4th frame of any animation, the code would look like this.
Player -> Physical Response (repeat enabled) -> Script Editor
Code: Select all
if(animpos==3)
{
    r=0;
}


If you didn't know, frame count starts at 0, and goes up. Also animindex is the number equivalent of the current animation. You can see the order, by looking at the existing animations, it is the order they come in.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Need Help With Collisions On Specifc Frames

Postby SuperNoob » Sat Sep 04, 2010 9:22 pm

Thanks man. So if I can't trigger events on specific frames, should I just split the animation up into two segments and trigger the event using a state check instead, and when objects collide with the actor itself, do the calculations ignore the alpha channel of a PNG file, and if I use a state check to trigger events on a collision and the colliding bounding boxes are already overlapping at the time the state check is verified, will the even still be triggered?
SuperNoob
 
Posts: 12
Joined: Thu Aug 26, 2010 6:55 pm
Score: 0 Give a positive score

Re: Need Help With Collisions On Specifc Frames

Postby skydereign » Sun Sep 05, 2010 1:00 am

Well you can trigger events on specific frames, just you are really triggering the collide event all the time. This way you can execute the code you want on certain frames, but all of the collision calls that aren't on those frames will not do anything. Not quite sure I follow that last bit, as what you are triggering is sort of ambiguous, but if the actors are already in collision, the collide event can still trigger, but only if you have repeat enabled. If not, the collision will only trigger once per collision.

Also something to think about, the actor can have various states that are unrelated, so you can create a second state variable to deal with other things. This would involve using switches withing the existing switch, which may or may not help you plan out what the actor is going to do. This is unnecessary but can prevent you from having to double/triple up certain events. For relatively simple games one is easy enough to do, but for example the current game I am making I use separate state variables for attack, move, overall, and click. Lastly, transparency is not considered in collisions.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron