Game Development Community

dev|Pro Game Development Curriculum

Fix for the onCollision detection when stepping

by Kevin Mitchell · 03/10/2013 (3:49 pm) · 3 comments

This fixes an issue I found with the engine where you need to detect the interaction with an object that you are stepping on. Before if the object meets the requirement of maxStepHeight then it is skipped as part of the collision detection.

This fix still allows the step but will still trigger the needed onCollision call when stepping on to the object.



Fix:
Player.cpp

Point3F Player::_move( const F32 travelTime, Collision *outCol )
.
.
.
.

            if (stepped)
            {
				//RPG EDIT
				//moved this further down to be able to still get a collision feedback for 
				//items that were calculated for allowed stepping
				//before if you are able to step on something the collision aspect is ignored
               //continue;
            }
         }

         // Pick the surface most parallel to the face that was hit.
         const Collision *collision = &collisionList[0];
         const Collision *cp = collision + 1;
         const Collision *ep = collision + collisionList.getCount();
         for (; cp != ep; cp++)
         {
            if (cp->faceDot > collision->faceDot)
               collision = cp;
         }

         F32 bd = _doCollisionImpact( collision, wasFalling );

		 
         // Copy this collision out so
         // we can use it to do impacts
         // and query collision.
         *outCol = *collision;

         //RPG EDIT
	     if (stepped)continue;

         // Subtract out velocity
         VectorF dv = collision->normal * (bd + sNormalElasticity);
         mVelocity += dv;



#1
03/11/2013 (9:50 pm)
Kevin,
Been following this since you posted the forum question. Am I getting the concept wrong or did you use this for the ladder?

Well, more specifically to tell the game engine you were standing on a 'ladder' object? Asking because us poor 'minimum-code' guys need an explanation. If so, this is awesome. If not....well I am lost yet again....

Ron
#2
03/13/2013 (4:26 pm)
I used this to tell me that I made contact yes.
#3
03/19/2013 (12:38 pm)
This is a cool fix Kevin. The video is a great way to show what it is for too!