Jump to content

Falling from height / respawn trigger


onaid
 Share

Recommended Posts

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 ?

 

 

 

post-9540-0-68770100-1454384943_thumb.png (all ok at this height respawn works)

 

post-9540-0-27326600-1454384955_thumb.png (at this height weird bounce thing goin on )

Link to comment
Share on other sites

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

  • Upvote 1

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

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...