stoping objects

Talk about making games.

stoping objects

Postby BogdansB » Sun Nov 04, 2012 3:36 pm

hey,
i have an actor , a ball , who ,when he collides with the player , rolls away. now i want to make him slowly stop after maybe 5 seconds. how do i do it?

thanks
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: stoping objects

Postby skydereign » Sun Nov 04, 2012 7:21 pm

I assume the actor is moving from velocity variables (instead of x+= ) since you mentioned collisions. One of the usual methods of decelerating is to multiply the velocity by a number slightly less than one. You only want that code to trigger after the collision, so you should use an actor variable to determine if the ball should slow down (and set it equal to 1 on the collision).
player -> Collision with ball -> Script Editor
Code: Select all
// your collision code
collide.slow_down = 1;


ball -> Draw Actor -> Script Editor
Code: Select all
if(slow_down==1)
{
    directional_velocity=directional_velocity*0.99;
    if(directional_velocity==0)
    {
        slow_down=0;
    }
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: stoping objects

Postby BogdansB » Tue Nov 06, 2012 7:04 pm

thanks .

now in the same game, when you make a score (soccer) the ball's position is x=0 and y=0. now when i play the game , the ball , when i score, goes from the 0,0 position with the same velocity how it went to the goal :S how do i do the ball standing on the 0 0 position?

i tried with xvelocity=0; yvelocity=0; doesnt work: the ball goes reaallyyy fast outside the view when the next "round" starts ...
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: stoping objects

Postby skydereign » Tue Nov 06, 2012 8:48 pm

Setting the actor's velocity variables to 0 should stop it. So either something else is increasing the variables, or you aren't setting the correct actor's xvelocity and yvelocity to 0. You'll need to post more about your setup.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: stoping objects

Postby Soullem » Tue Nov 06, 2012 11:08 pm

Hey I made a soccer game that sounds like it could help you out a lot! its called 2 man soccer, and its in game development . Also when you are setting the velocity, what actor has the script for this? if it isn't the ball try adding

ball.xvelocity=0;
ball.yvelocity=0;

Heres a link to my game

http://game-editor.com/forum/viewtopic.php?f=4&t=12365
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: stoping objects

Postby BogdansB » Wed Nov 07, 2012 3:34 pm

hmm its not in the ball actor but i did ball.x ..... and it still glitches. and i still dont know what the problem is , even after watching your game which is really good :D
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: stoping objects

Postby Soullem » Thu Nov 08, 2012 2:34 am

Wait are you using directional velocity in your ball movement script? If so you might have to set

ball.directional_velocity=0;

Im not sure though, and thanks for the compliment :D
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: stoping objects

Postby skydereign » Thu Nov 08, 2012 2:51 am

Setting any velocity to zero will stop the actor, even if it uses the other velocity scheme. But BogdansB, we can't help you unless you post more about your setup. This should be pretty trivial, but unless we actually know what is happening in your game, all we can do is guess. If you can post the ged and data. Otherwise post all the code that handles movement for the ball.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: stoping objects

Postby BogdansB » Fri Nov 09, 2012 6:57 pm

here it is
Attachments
ice.ged
(15.31 KiB) Downloaded 131 times
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: stoping objects

Postby skydereign » Fri Nov 09, 2012 7:55 pm

So this is caused by a bug in gE. The slow down code I gave you references directional_velocity in the ball's draw actor. This can cause problems when moving the actor, because xvelocity and yvelocity are updated automatically when the actor is moved. Namely if you put x+=5 in an actor's draw event, they will have an xvelocity of 5, even if you didn't ever set it. Easiest way around it is just to create a new ball actor. So in bg's timer event, destroy the ball actor, and create one in the center.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: stoping objects

Postby BogdansB » Sat Nov 10, 2012 8:40 am

ok its working :)
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: stoping objects

Postby BogdansB » Tue Nov 13, 2012 5:35 pm

and another problem :S

since i made my score growing untill 10 and then get 0 , the code doesn'T work
Code: Select all

if(green_points.textNumber==10)


{
green_points.textNumber=0;
 }

whats wrong?



BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: stoping objects

Postby skydereign » Tue Nov 13, 2012 9:09 pm

textNumber isn't normal. Therefore, I don't recommend you use textNumber like a normal variable. Instead you should make a variable green_score or similar, and use that instead. Using it like you have has been reported to give problems (probably due to textNumber's questionable type), so that could be the reason.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: stoping objects

Postby BogdansB » Fri Nov 16, 2012 4:54 pm

works , thanks :P
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest