runSurfaceAngle Over 89 Breaks Gravity

Expanding and utilizing the engine via C++.
2 posts Page 1 of 1
Steve_Yorkshire
Posts: 285
Joined: Tue Feb 03, 2015 10:30 pm
 
  by Steve_Yorkshire » Fri Feb 16, 2018 11:36 pm
Setting PlayerData runSurfaceAngle to 90 or more in the Player's datablock means that the "Fall" flag never set, so the player can only go upwards or walks in the air.

This is actually logical, as the test for player contact is directly vertical to the playerObject and >89 degrees is horizontal.

So if the player runs up a steep slope and then steps off into thin air, they stay hovering and can never move back downwards.

Obviously this should simply be avoided by using sensible values in the datablock, but just incase for those of us who might make a mistake (*cough* it only took me days to work out what the issue which I was having was :oops: ) it might be an idea to add a little safety check to the code.

Engine/source/T3D/Player.ccp
bool PlayerData::preload(bool server, String &errorStr)
{
   if(!Parent::preload(server, errorStr))
      return false;
//...

   if (runSurfaceAngle > 89)//yorks safety first
   {
	   runSurfaceAngle = 89;
	   Con::warnf(ConsoleLogEntry::General, "PlayerData::preload: runSurfaceAngle exceeds 90 degrees. Resetting to 89 degrees.");
   }//yorks end safety first

   runSurfaceCos = mCos(mDegToRad(runSurfaceAngle));
   jumpSurfaceCos = mCos(mDegToRad(jumpSurfaceAngle));
   if (minJumpEnergy < jumpEnergyDrain)
      minJumpEnergy = jumpEnergyDrain;   

   // Jetting
//...
Jason Campbell
Posts: 266
Joined: Fri Feb 13, 2015 2:51 am
 
by Jason Campbell » Sat Feb 17, 2018 3:34 pm
Thanks Steve. Though I doubt this will affect me, it's good to know. Who now's maybe if someone was trying to implement parkour or the scene at the end of Doctor Strange.
2 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest