How do I keep momentum through a wrap?

Just started using Construct 2? Post your questions here

Post » Wed Jun 01, 2016 5:42 am

I'm working on a basic 'asteroids' clone, and I've hit a snag with the wrap behavior. When the ship (I'm only as far as the ship and its movement mechanics atm) crosses the edge, it comes to a complete stop- advancing as normal across the edge and onto the other side of the screen from there if you keep holding the accelerator. This seems to be because I'm using the Physics behavior for my movement; I've noticed that using 'custom movement' like they do in the demo works fine. All the same, I wonder if there's a way to use the physics behavior with wrap without losing all momentum at the edge of the screen.

PS: sorry, but I can't include a .capx of the project. I'm currently trying to resolve a problem I'm having where Construct 2 refuses to save to that format.
B
10
S
2
G
4
Posts: 10
Reputation: 2,566

Post » Wed Jun 01, 2016 7:10 am

Dont use the wrap ? Use two inmovable physics objects to mark the bondarys?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jun 01, 2016 11:06 am

Well, yeah; but what if I actually want the wrap behavior, but on an object whose movements are governed by the physics behavior? It seems like there should be a way to do that, but being quite new to this I have no idea what it might be.
B
10
S
2
G
4
Posts: 10
Reputation: 2,566

Post » Wed Jun 01, 2016 11:25 am

Well, yeah, actualy that is a foolish wish. (excuse the word). You have to stay in the context.

You move the objects with physics, then you got to change its motions with physics. Stopping it = changing its motion.
Any other way will break the physics world.

Because the physics world depends on tweening little changes that happen in little steps over time. Every action has a reaction. Nothing, absolutly nothing can change position in zero time, that would be magic and break the physics world.

If you change things in zero time. You are in the quantum world. (or in some Fairy World) With totaly differend rules. As you know, both worlds are not compatible (yet).
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jun 02, 2016 3:45 am

I think I get that much of it; but surely there is some way to get an object governed by the physics behavior which exits one side of the screen to enter on the other side moving at the same speed and angle as it had left. But I if I understand you, what you're saying is that there's no shortcut to get that effect, and if I want that to happen I'll actually have to set up a function to do it myself rather than be lazy and use Scirra's fancy pre-packaged screen wrap?

Being the lazy dude I am, I was hoping to avoid having to do that; but I'm not all that surprised to hear it. Either way this is going to go way faster than coding it by hand. Thanks for the help. ^_^

PS: My first instinct is to have sprites whose center hits the edge reassign their position to the corresponding position on the opposite edge; is that how you'd go about it, or is there a better way?
B
10
S
2
G
4
Posts: 10
Reputation: 2,566

Post » Thu Jun 02, 2016 8:17 am

I have not seen one wrap a physics object yet.
I suppose the solution is in this direction, since wrap dont have a 'on wrap' condition.

https://drive.google.com/open?id=0B1SSu ... 3NpQTlEeWM

Overlap = just lazy. Can do it with abs(distance from center of the window) too. But it would not be a visual example.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jun 02, 2016 9:56 am

Ok; that makes perfect sense. I hadn't considered using other sprites as a way to define the wrap. Thank you for your help; this should be useful for a number of things beyond screen wrapping.
B
10
S
2
G
4
Posts: 10
Reputation: 2,566


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests