onaid Posted February 2, 2016 Share Posted February 2, 2016 https://drive.google.com/folderview?id=0BxWM6ILP8Pf9b0dwcU5Vc0NyZGM&usp=sharing Need a little help with falling from height , i have attached a sample project where i have followed Aggrors tutorial on respawning player. all works fine , except when i move the respawn trigger box any lower than the height reference box i have placed in the scene , my fps player bounces between respawn trigger and respawn point ? the final result i wish to get is have the player fall for some fair time then respawn. I found before if i had the respawn trigger too far down my player would die on impact and not respawn, bring the respawn trigger box up and all is ok but player dosent fall for as long as i want, i over came this by changing this function Script:Collision(entity,position,normal,speed) if speed>200 then self:Hurt(100) end end speed from 20 to 200 allowed me to achive greater fall distance, but if i lower the respawn trigger box any lower than what is in attached project i get the bounce thing happening, if that makes any sense... also tried changing the if speed to higher numbers and self hurt to 0 but no change? thank you in advance also have tried changing the respawn trigger collision to character this works randomly ? sometimes i bounce somtimes i dont ? (all ok at this height respawn works) (at this height weird bounce thing goin on ) Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 3, 2016 Share Posted February 3, 2016 Could you clarify the 'bounce'? Do you switch position between death and restart position? Or is your player jumping in the air after re-positioning? Quote Link to comment Share on other sites More sharing options...
onaid Posted February 3, 2016 Author Share Posted February 3, 2016 https://drive.google.com/file/d/0BxWM6ILP8Pf9UlV1a2FlTm9jVXM/view?usp=sharing short video of he bounce thing. https://drive.google.com/file/d/0BxWM6ILP8Pf9anVqb2tWelJKaVk/view?usp=sharing zip file for project. Quote Link to comment Share on other sites More sharing options...
Brutile Posted February 3, 2016 Share Posted February 3, 2016 I've had that problem before. It's because your velocity isn't being reset and you're falling too fast and going through the floor. You'll want to set your Velocity to Vec3(0) Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 3, 2016 Share Posted February 3, 2016 The character controller is a custom physics object so sometimes there are quirks with it. Some entity physics commands work with it and some do not. As far as the issue here, it appears just setting the player's physics mode to rigid body physics momentarily resolves the "bouncing". Script.respawnpoint = "" --entity "Respawn point" function Script:Collision (entity, position, normal, speed) if(entity:GetKeyValue ("name") == "Player") then spawnPos = self.respawnpoint:GetPosition () entity:SetPhysicsMode(Entity.RigidBodyPhysics) entity:SetPosition (spawnPos) entity:SetPhysicsMode(Entity.CharacterPhysics) end end 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
onaid Posted February 4, 2016 Author Share Posted February 4, 2016 I've had that problem before. It's because your velocity isn't being reset and you're falling too fast and going through the floor. You'll want to set your Velocity to Vec3(0) thanks for your reply it is set to zero in default fps .lua am i looking at the right line ? Quote Link to comment Share on other sites More sharing options...
onaid Posted February 4, 2016 Author Share Posted February 4, 2016 The character controller is a custom physics object so sometimes there are quirks with it. Some entity physics commands work with it and some do not. As far as the issue here, it appears just setting the player's physics mode to rigid body physics momentarily resolves the "bouncing". Script.respawnpoint = "" --entity "Respawn point" function Script:Collision (entity, position, normal, speed) if(entity:GetKeyValue ("name") == "Player") then spawnPos = self.respawnpoint:GetPosition () entity:SetPhysicsMode(Entity.RigidBodyPhysics) entity:SetPosition (spawnPos) entity:SetPhysicsMode(Entity.CharacterPhysics) end end thanks mate that has done the trick it appears to be working fine now , i can move the respawn trigger way down lower and no more bounce thing going on , thanks a bunch again for everyones help Quote Link to comment Share on other sites More sharing options...
Brutile Posted February 4, 2016 Share Posted February 4, 2016 thanks for your reply it is set to zero in default fps .lua am i looking at the right line ? Not quite. You are sending the input to the character controller, but the character controller is automatically applying gravity and handling the velocity, so if you send 0 for the movement, you will still get gravity being applied. Calling self.entity:SetVelocity(Vec3(0)) should do the trick, but as macklebee said, some physics commands don't work as expected with character physics. If this doesn't work, then you could try applying a very small jump amount to the character controller input. This may work to reset the velocity. Quote Link to comment Share on other sites More sharing options...
onaid Posted February 4, 2016 Author Share Posted February 4, 2016 Not quite. You are sending the input to the character controller, but the character controller is automatically applying gravity and handling the velocity, so if you send 0 for the movement, you will still get gravity being applied. Calling self.entity:SetVelocity(Vec3(0)) should do the trick, but as macklebee said, some physics commands don't work as expected with character physics. If this doesn't work, then you could try applying a very small jump amount to the character controller input. This may work to reset the velocity. thanks mate macklebee's modified script has done the trick i rekon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.