YouGroove Posted February 23, 2014 Share Posted February 23, 2014 Well i don't use character controller on player as i want only X/Y axes for 2.5D game. I got some jumping code where i use AddForce on Y , and detect when Velocity go down from highter jump point reach in Y. Than i detect when Velocity passes > 0 when character is beginning the first boucing , then i use SetPosition to cancel physics on character.and have it stay on floor instead of bounce. function Script:Movement() if self.jumping == 0 then pos = self.entity:GetPosition() Xplus=(App.window:KeyDown(Key.S) and 1 or 0) Xmoins=(App.window:KeyDown(Key.Q) and 1 or 0) playerx = (Xplus- Xmoins) * Time:GetSpeed() * self.moveSpeed if Xplus >0 then self.orient = 1 end if Xmoins >0 then self.orient = -1 end pos.x = pos.x + playerx end jump=(App.window:KeyDown(Key.X) and 1 or 0) if self.jumping == 0 then if jump == 1 then self.jumping = 1 self.entity:AddForce ( 0, 200, 0 , true ) end end if self.jumping == 1 then vel=self.entity:GetVelocity(true) if vel.y<0 then -- self.entity:AddForce ( 0, -50, 0 , true ) self.jumping = 2 end end if self.jumping == 2 then vel=self.entity:GetVelocity(true) if vel.y > 0 then -- self.entity:AddForce ( 0, -50, 0 , true ) self.jumping = 0 pos= self.entity:GetPosition() self.entity:SetPosition(pos) end end self.entity:PhysicsSetRotation( 0, 90*self.orient, 0 ) -- move the controller in the rotation of the player if self.jumping == 0 then self.entity:PhysicsSetPosition(pos.x,pos.y,self.zdepth,0.5) end end The problem is that keeping pressed jump sometimes you can continuously jump ? Just guess if someone have a working 2.5D lua code ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
DudeAwesome Posted February 23, 2014 Share Posted February 23, 2014 http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitygetairborne-r698 to check if you stay on ground Quote It doesn´t work... why? mhmmm It works... why? Link to comment Share on other sites More sharing options...
YouGroove Posted February 23, 2014 Author Share Posted February 23, 2014 Thanks, but Airborne is when you jump using character controller and is jumping feature. I use simple physics so can't simply work. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
DudeAwesome Posted February 23, 2014 Share Posted February 23, 2014 ok then it should possible to ask for a linear velocity to the bottom (if player falls down) if there is one you should disable the jump. like: is my player falling? yes -> disable jump is my player falling? no -> enable jump other solution: if player have a collision with an entity with the key "ground" enable jump. if not disable jump. Quote It doesn´t work... why? mhmmm It works... why? Link to comment Share on other sites More sharing options...
YouGroove Posted February 23, 2014 Author Share Posted February 23, 2014 THanks, bu it is some logic i followed, but i got strange stuuf happening, and trying debug crashed ? Perhaps i'll try the key "groud", the problem is that i will need to attach script to each BSP ground, so it just complicated more the workflow But seems the more secure way to do it for now. Quote Stop toying and make games 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.