How can a 3d shape walk or drive up ramps or wedges?

0 favourites
  • 12 posts
From the Asset Store
Character Sprite Pack: Walk 4 Directions made in illustrator
  • I have a 3D shape with car controls. I want it to be able to drive up a ramp (wedge shape) and launch off.

    I found this thread here which addresses the same issue:

    https://www.construct.net/en/forum/construct-3/how-do-i-8/anyone-figured-go-3d-wedge-171152

    WackyToaster your example works, but I noticed some bugs when changing the player speed. if I increase the player speed in your example, sometimes it will drop through the slope when it is halfway up.

    when i implemented the example into my game, a 3d shape with car controls, the player (if moving too fast) will hit the slope and stop. but when the player is moving slower, it moves right up the ramp like it should.

    any idea why player speed might affect how the player climbs the slope?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Probably when moving fast the objects move too far so it incorrectly guesses which way to resolve the collision.

    Here's a slightly different way to do it that supports rotated boxes and wedges. It treats the player as a ball. The collisions are resolved in the closest direction so when on a slope you'd slide down.

    dropbox.com/scl/fi/06pnm5xx1c1z92h9u09vl/3d_box_and_wedge_collsion_response.c3p

    You can break this too. With a radius of 16 you can go up to 1000 pixels per second and still work at 60fps. 1000/60 = 16. Higher speeds can pass though walls. To fix you can use larger radius', slower speeds, or move in multiple smaller steps per frame so you can check multiple times.

  • R0J0hound sorry for the late reply. I didn't see a notification, but I really appreciate the quick response and solution offered.

    I am going to play around with this to get a hang of it and then will respond with questions. But this looks neat! Thank you!

  • how can I make the sprite go up the ramp faster?

  • The method works by finding the closest point on the shape’s surface and pushing the object away from that. A side effect of that is wall sliding. Guess you don’t like how it’s slower moving up a slope because of that.

    There isn’t really a fix with this method. Maybe one of the other ideas floating around would help.

  • R0J0hound how is it achieved in the JS demo "Complex terrain" under examples? Perhaps that can give some clues to convert them to regular events. I'm affraid i don't understand the code.

  • I’d have to look.

    I’d think raycasting in the z direction would give the z position on the slope without sliding. There are various ways to do that but projecting the xy position onto the equation for the plane of the top face of the slope is one idea. But youd have to do some checks to consider what direction you were moving into the wedge so you’d hit it from the side and such.

    Or actually we could take the push out direction in my example and if it’s mostly a change of z then do the z ray cast.

  • Good afternoon friend, please help me with the behavior [BEHAVIOR] ISOMETRIC, you wrote a comment - I'm not working on this anymore, but probably the best way to improve performance is to have less objects have this behavior. For instance the ground could be sorted once and left as is.

    What did you mean by - For instance the ground could be sorted once and left as is.

  • SpaceCore, please dont hijack topics. Make your own if you require help.

  • Had a look. Looks like that example just has a terrainheight function that gives the z height of any xy point on the terrain. They used a bunch of formulas to define the shape of the terrain. Cool but not necessarily the easiest to tweak. They could have sampled a greyscale image or used a noise function to define the shape as well.

    The idea could be used with wedges. Basically pick the wedges under an xy, and calculate the z with some math. The main issue is that method isn’t enough to deal with walls too. It’s mostly good for smooth terrain. So wall logic would be separate.

  • The method works by finding the closest point on the shape’s surface and pushing the object away from that. A side effect of that is wall sliding. Guess you don’t like how it’s slower moving up a slope because of that.

    There isn’t really a fix with this method. Maybe one of the other ideas floating around would help.

    I wish there was a way to speed up the upslope sliding while in contact with the wedge. But I believe you if you say there's no easy fix.

    I appreciate your help R0J0hound!

  • Well nothing came to mind when I wrote that. I’ve already become unfamiliar with what my example did.

    Well the idea is simple. Find if a ball shaped player is overlapping the wedge shape. If it is move out in the closest direction. And since gravity and the motion directions aren’t parallel with the slopes sliding occurs which is semi realistic.

    There are likely many solutions. I mentioned the idea to push up maybe when on a slope, but it would require logic to not push up when moving from the sides.

    Possibly we could guess when you want to push up by looking at the z component of the normal.

    Another idea is to disable gravity when on the ground. Again you should be able to know that based on the z of the normal, or we could make the collision detection return what feature of the wedge we are pushing out of. Then when on the ground we could make the motion be parallel to the slope so no sliding would occur. It would require rotating the motion axis’ with the normal.

    Third idea is a vertical ray cast to find the ground level and just change the z to that.

    Anyways most of those would work best by scrapping my example and making a new one.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)