yvel

Game Editor comments and discussion.

yvel

Postby ESL » Mon Jun 03, 2013 7:38 am

What is the purpose of a statement like yvelocity=yvel? It seems to be stating the obvious.
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: yvel

Postby skydereign » Mon Jun 03, 2013 7:42 am

I assume you came across this in a collision event. yvel is not a built in variable, it stores a value.
Code: Select all
double yvel = yvelocity; // this creates a variable that remembers the value of yvelocity at this point
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000,1.000000, 0.0, 0.0);
// this call to PhysicalResponse will set yvelocity and xvelocity to 0
// note though that yvel is not set equal to 0, as it still holds the value it had at the first line

yvelocity = yvel; // this now sets yvelocity back to what it was before the collision

The reason you do that is to prevent the player from sticking to the wall. Normally after PhysicalResponse, the xvelocity and yvelocity variables are set to 0, which stops movement. In cases where you use that (collisions with walls) we only want to stop the xvelocity.
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