Slopes and player angle. Is there a solid solution?

Get help using Construct 2

Post » Mon Sep 19, 2016 6:32 pm

Hi there,

currently I am making a game where the player can move his tank left and right, where I want it to be able to go uphill and downwards.

Now I've been searching the forums and seen many examples, but what I can't find is any example that works really well.

Most examples have this 'bug' in them that if the player moves at low speed for example, the player bugs out unable for the system to decide which angle the player should be at. So you get this buggy superfast player flickering between the two angles.

Also should I set the collision polygon to the bounding box of the tank? I tried making it very narrow as sometimes it would work better. But what's the best setting?

Same for the offset. Is '10' the best setting for the offset? I don't quite understand what it does.

And should I use every tick or rather every 0.01 seconds?

This is what I got:

Image

Image

I fiddled around wiith various settings but nothing perfect came out of it.

And then there's the solid blocks. I tried leaving a little space between them, or overlap more, I really want the player to be able to smoothly drive the terrain up and down, back and forth.

As you can see there are a lot of things going on. Did anyone find a really good example or made one I could use for this type of game?

P.S. The speed and acceleration of the player tank also seems to play a role in how easy the tank climbs the hill (less buggy).

I'd be very grateful if someone could help me out!

Regards - R
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Mon Sep 19, 2016 11:49 pm

The offset in overlaps at offset is as if the sprite was moved by that amount before checking for collision.

Anyways the typical solution is to use detector sprites at the front and back of the tank. You position the detectors and then move them up or down till they touch the ground, then the angle between the two is the angle to make the tank.

Here's one possible solution:
https://dl.dropboxusercontent.com/u/542 ... imple.capx

And here's another that samples more points.
https://dl.dropboxusercontent.com/u/542 ... mple2.capx
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999

Post » Tue Sep 20, 2016 5:42 am

Thanks R0j0hound!

One of the first things I changed to your samples was the max. speed of the player moveable object to see if there's an issue.

I find that in my own capx I encounter the same problem; the lower the max speed, the more difficult it gets to climb the terrain.

Try setting the max speed at 40 for example with acceleration and decceleration of 30. You should see what I mean. The object gets 'stuck' and won't climb the terrain until you try moving it back and forth again.

Any ideas?

Thanks and regards - R
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Tue Sep 20, 2016 6:21 am

That's an artifact of the platform behavior getting stuck on the slope. One idea could be to make the object with the platform behavior a smaller square that doesn't rotate in the middle and then positioning a rotated tank sprite on top of it. Other ideas include using the physics behavior for the motion or maybe implementing motion completely with events so then you could address issues on a case by case basis.
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999

Post » Tue Sep 20, 2016 12:41 pm

Hi,

thanks for your reply.

I tried the first suggestion, I pinned the chassis of the tank to be rotated onto a square that doesn't rotate but does hold the platform behavior. It actually worked worse than what I had now. It would get stuck more easily.

I don't quite understand the physics suggestion, I mean I tried applying physics to the tank, but now it seems to climb the slope pixel layer by pixel layer.

I thought coding the part was a good idea, I tried that however I'm not sure how to make the tank go 'up' at the right angle.

So I tried fiddling with the bullet behaviour and custom controls but I can't quite figure that one out to make it work properly.

Hmm.. about to give up on this one.. surely there must be a way.
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Tue Sep 20, 2016 6:11 pm

Here's an example of using physics:
https://dl.dropboxusercontent.com/u/542 ... ysics.capx
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999


Return to How do I....?

Who is online

Users browsing this forum: TRMG and 38 guests