How do I use Screen Wrap behavior with Physics?

Get help using Construct 2

Post » Thu Mar 19, 2015 4:14 am

Answer.... YOU DON'T!

This is the code to make the player in an asteroids like game screen wrap and us physics.

Screen wrap with physics.png


Do not give the players the wrap behavior. Give the player two instance variables to store the x and y velocity of the physics behavior when they got outside the layout. Disable physics when outside of layout. Reset the x and y depending on witch side of the layout the player left. (compare Players x/y with the layout width/height) then reset both the x and y velocitys and Enable physics.

WA LA! Easy.... not really. Its a mouthful but its not to hard just hard to type out.
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 12
Reputation: 249

Post » Thu Mar 19, 2015 5:24 am

Nice, but you should post this as a tutorial.
B
47
S
11
G
5
Posts: 554
Reputation: 6,576

Post » Thu Mar 19, 2015 11:29 am

Sorry dude, but I did a quick test, and both Wrap and Physics behavior worked perfectly in a same object.
Image
B
15
S
7
Posts: 126
Reputation: 1,835

Post » Sun Apr 24, 2016 11:20 am

I just tried it in Construct 2 r227 and it does not seem to work if you combine wrap and physics. Is it possible to change/fix this?
But I will try the example code from above.
B
51
S
15
G
5
Posts: 681
Reputation: 8,399

Post » Sun Apr 24, 2016 6:18 pm

The idea above it to save the velocity, move, then set the velocity from the saved one. Basically the reason fro this is moving the object changes the velocity, which can be useful for things like using dragndrop to throw physics objects.

Alternatively the chipmunk behavior works fine with the wrap behavior by default.
B
85
S
27
G
78
Posts: 5,010
Reputation: 54,254


Return to How do I....?

Who is online

Users browsing this forum: 20170217, alimuqaddas, Kenthria, LukeW, theGioM and 7 guests