gamecreator Posted March 30, 2017 Share Posted March 30, 2017 When the character controller jumps on a flat surface or up hill, jumps seems to be ok but when it jumps downhill, the jumps become smaller and smaller the steeper the hill is. Was visible in this demo as well: www.leadwerks.com/werkspace/topic/15913-my-first-demo/ Relevant code, just in case I'm doing something wrong: bool App::Loop() { float startheight, maxheight; if(window->Closed() || window->KeyDown(Key::Escape)) return false; float move = (window->KeyDown(Key::Up) - window->KeyDown(Key::Down)) * 6; float strafe = (window->KeyDown(Key::Right) - window->KeyDown(Key::Left)) * 6; float jump = window->KeyDown(Key::S) * 10; if(!player->GetAirborne()) { if(jump>0) { startheight = player->GetPosition().y; maxheight = startheight; } } else { jump = 0; if (player->GetPosition().y > maxheight) maxheight = player->GetPosition().y; } player->SetInput(0, move, strafe, jump); camera->SetPosition(player->GetPosition(true), true); camera->Move(0, 0, -10); Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); context->SetColor(1.0f, 1, 1); context->DrawText(String(maxheight-startheight), 10, 10); context->SetBlendMode(Blend::Solid); context->Sync(); return true; } The uphill jump height actually also gets just a touch bigger the steeper the hill but it's not anywhere as drastic. Link to comment Share on other sites More sharing options...
Josh Posted March 30, 2017 Share Posted March 30, 2017 Are they moving downhill when jumping, or does this happen when they are jumping in place? 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 More sharing options...
gamecreator Posted March 30, 2017 Author Share Posted March 30, 2017 Jumping in place jumps the full height regardless of the slope it's on. Only while moving downhill is the jump height reduced, apparently proportional to the slope angle. Link to comment Share on other sites More sharing options...
Jazz Posted March 30, 2017 Share Posted March 30, 2017 This happens in Rick Powers too (lua). 1 --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
Josh Posted March 30, 2017 Share Posted March 30, 2017 This could be considered correct behavior. If your velocity is negative then jumping would result in a lower velocity than if you are standing still. However, it may make more sense to add the jump velocity to the velocity of the object the character is standing on. That way if you are in a falling elevator, your jump will still be relative to the ground. 1 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 More sharing options...
gamecreator Posted March 30, 2017 Author Share Posted March 30, 2017 I totally get that it's a balancing act between what's physically right and what feels and looks natural. But right now the height issue is very extreme and unnatural for those who have played any sort of jumping games. It literally does something like this. The same distance across but you can't make a jump because you're running on a slope. It sounds like your solution above may fix this though. 1 Link to comment Share on other sites More sharing options...
Josh Posted March 30, 2017 Share Posted March 30, 2017 Ha, makes sense. Since you are pushing off against a stationary object, it makes sense the jump velocity would be the same. Although if you were running downhill, I bet the second image is what would actually happen. I agree with you and will see if I can change this behavior. 2 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 More sharing options...
gamecreator Posted March 31, 2017 Author Share Posted March 31, 2017 Appreciate it Josh. Here's a video too with an exaggerated jump height. Note how the jump off the sloped ground gets less than half the usual height. 2 Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 31, 2017 Share Posted March 31, 2017 NIce video gamecreator. couldn't have shown it better. 1 Link to comment Share on other sites More sharing options...
Josh Posted April 1, 2017 Share Posted April 1, 2017 Have you thought about using SetVelocity to set the character's vertical velocity to zero when they jump? Vec3 v = player->GetVelocity() v.y=0 player->SetVelocity(v) 2 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 More sharing options...
Jazz Posted April 1, 2017 Share Posted April 1, 2017 Have you thought about using SetVelocity to set the character's vertical velocity to zero when they jump? Vec3 v = player->GetVelocity() v.y=0 player->SetVelocity(v) This works but the jump is still not high enough. The y velocity is negative on a downward sloped jump. The following seems to work but note I didn't test it very much... local tmp = self.entity:GetVelocity() if tmp.y < 0 then tmp.y = math.abs(tmp.y) --compensate for negative velocity self.entity:SetVelocity(tmp) end 1 --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
gamecreator Posted April 3, 2017 Author Share Posted April 3, 2017 Have you thought about using SetVelocity to set the character's vertical velocity to zero when they jump? Good thought. The height from a flat jump remains the same but the sloped jump improved from 5.77 to 8.71. I'd love to see it get even closer to the full height (ideally the whole thing). Here's what the video looks like now: Link to comment Share on other sites More sharing options...
Jazz Posted April 3, 2017 Share Posted April 3, 2017 Good thought. The height from a flat jump remains the same but the sloped jump improved from 5.77 to 8.71. I'd love to see it get even closer to the full height (ideally the whole thing). Here's what the video looks like now: My solution didn't work for you? 1 --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
gamecreator Posted April 3, 2017 Author Share Posted April 3, 2017 Just tried it. To my surprise it looks like it works so far! I'll have to test moving platforms as well later. Thanks very much SGB and Josh for the original suggestion. 1 Link to comment Share on other sites More sharing options...
gamecreator Posted April 13, 2017 Author Share Posted April 13, 2017 Worth noting that the one problem with the above solution is that when a character lands, it has negative velocity for a frame. As such, if you hold down the jump button, it will jump higher and higher (and then fall through the ground with enough velocity). This isn't an issue for me because I don't plan on allowing this jump (you can't hold jump and keep jumping) but I have to keep this issue in mind. I'm hoping Josh still intends to fix the character controller so we don't keep coming up against unexpected exploits. Link to comment Share on other sites More sharing options...
Admin Posted March 11, 2019 Share Posted March 11, 2019 I believe this is solved, from your other report that showed this behavior: 1 Link to comment Share on other sites More sharing options...
Recommended Posts