Jump to content

Problems Trying to Get Walking on Ceiling Working


mdgunn
 Share

Recommended Posts

This seemed like it would be essentially a fairly simple thing to do but I can't get it to work yet.

 

Maybe someone can tell me this is just a non-starter idea and to stop right now! :)

 

I considered rotating the whole map and plonking the player back down again (hiding the transition) but ideally I'd like the player to do it for real.

 

Anyway in pursuing the normal option of not rotating the map I have so far got gravity reversing OK but I can't get the player to turn around so they are actually upside down.

 

I tried to set a rotation on the player entity Z axis but is seems to get wiped out after I set it. I guess it is later computed by something else in the normal course of things and my changes are lost.

 

Here is my function which when called seems to set a rotation but then later lose it when I print out player rotation values in UpdateWorld() of FPSPlayer.

 

Can anyone tell me what I need to do instead?

 

 

function Script:FlipPlayer()--in
if self.entity:GetKeyValue("inverted","false") == "false" then

 -- Get Current rotation
 playerRotation = self.entity:GetRotation()

 if playerRotation ~= nil then

   local rotx = playerRotation.x
   local roty = playerRotation.y
  -- rotate the player to be upside down
   local rotz = playerRotation.z + 180

  self.entity:SetRotation(Vec3(rotx, roty, rotz))
  -- Check our update held by printing it out again
  local newRot = self.entity:GetRotation(true)
  System:Print("-new playerRotation rotx="..newRot.x)
  System:Print("-new playerRotation roty="..newRot.y)
  System:Print("-new playerRotation rotz="..newRot.z)  

  self.entity:SetKeyValue("inverted","true")
  self.component:CallOutputs("OnFlip")

 end   
end
end

Link to comment
Share on other sites

The player controller is a custom object that doesn't necessarily work like other objects in the physics engine. The character controller does not tip over or rotate on the x/z axis. You would probably have to either make your own controller or fake it.

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

Thanks for the response....

 

OK, well I tried rotating the camera to sort of fake it, and got that to hold values OK but the controls were the wrong way round (as you'd expect). I considered flipping them but at this point it felt like faking it might throw up more problems than just getting the player to rotate properly so I pursued (without success) what seemed the more sensible option of trying to rotate the player instead.

 

Maybe I can get some answers from Josh on this. I'll see what happens,

 

Thanks,

 

Michael

Link to comment
Share on other sites

At the top of Script:UpdatePhysics() add

 

self.entity:AddForce(0,10,0)

 

This will make you float as if gravity was reversed. Play with it to get the right number for your game. Using the mass generally works fine.

 

For your jumping you will need to do a bit more work. You have to make sure that you are touching the ceiling (raycast up to make sure it's there), you need to cancel the airborne check, you need to set the jumpforce to -1 and manually push the player.

 

self.entity:AddForce(0,(mass * jumpforce ) *-1,0)

This is a good place to start.

 

Also, you may want to rotate the camera on the z axis by 180, and reverse the mouse look controls (multiplying the result by -1 usually reverses it.)

 

Now the hard part. Your arms and weapons need to be rotated too. Also if you are able to carry things

 

Start with walking

Then Jumping.

Carrying seems to work fine.

Then weapons and arms.

Edited by Einlander
Link to comment
Share on other sites

The player controller does a lot of special physics stuff and doesn't support any orientation except +Y = up. You'd really have to implement your own character controller with this behavior in mind.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Thanks for the response Einlander. I think that informaiton will save me a lot of time.

 

The player controller does a lot of special physics stuff and doesn't support any orientation except +Y = up. You'd really have to implement your own character controller with this behavior in mind.

 

Can implementing your own controller be done fully from Lua? Do you say implement new one because the amount of changes needed in FPSPlayer would not be worth messing about with and better to build up from scratch as exactly what needed for my specifics?

 

Thanks,

 

Michael

Link to comment
Share on other sites

maybe you could make the fosplayer an other physics object like in the kill() function (i am not sure which) where the camera gets attached to an low poly sphere to make it look like you are falling to the ground. so in the theory you could change the player to a box , put in the rotation, and them put it back to the normal pysics option and shape. it would be calculated so fst that you could not see this ingame probably

Link to comment
Share on other sites

  • 2 weeks later...

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...