Layer Rotate and Collision

Get help using Construct 2

Post » Tue Jan 10, 2012 4:24 pm

In playing with rotate layer I'm finding some unusual interactions.
in the linked example. Layer 0 has a series of TiledBackground objects with Solid. Layer 1 as a sprite object with platform behavior. [Space] will rotate layer 0 90 degrees. [z] toggles sprite between layer 0 and layer 1.

The unexpected result of rotating layer 0, is the sprite on layer 1 collides with the solid objects on layer 0 as if they never rotated.

This oddity is removed if sprite and solid objects are on the same layer. Toggled in the example with [z]. That said when moving sprite to a rotated layer 0 it's position seems to shift relative to the rotation of the layer.

Assuming this is normal behavior. What would be a good way of countering this effect? My goal is to have several different layers each with independent rotations, that will interact with a platform behavior

My first thought is to simply have each series of objects pinned to a Pivot object. That will do the rotation. This solves the problem. but does not allow me to use Rotate layer. Which I'm trying to utilize for the competition.

Links
   Link to demo example
link to .Capx

Thanks for any help.
B
83
S
12
G
9
Posts: 99
Reputation: 9,478

Post » Tue Jan 10, 2012 5:01 pm

I provide a capx in this topic.
It's with physic objects but the logic for platform/solid is the same.

It's a workaround, while waiting/hoping @Ashley might add some way to get the relative position of an object (the position on screen once rotated. Currently, its X and Y and angle don't change since it is its "rendering context", the layer that gets rotated)
Something like Sprite.x(Layer) like for the mouse object.
It's manageable without, but that would really ease up a lot af things. Same for Sprite.Angle(Layer).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786

Post » Tue Jan 10, 2012 6:34 pm

I didn't see the other topic. Thank you! that provides insight into what's going on and your example further helps me understand what I need to do in working around it.
B
83
S
12
G
9
Posts: 99
Reputation: 9,478

Post » Tue Jan 10, 2012 8:11 pm

It's a known bug that objects on different layers collide as if their layers weren't scaled/rotated/parallaxed at all. (Objects currently only collide taking in to account their X, Y, width and height, if that helps you imagine what's happening.) Hopefully this will be fixed in future, but it's a little complicated, I'm not sure it'll be done in time for the competition deadline.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,208

Post » Tue Jan 10, 2012 8:47 pm

Thanks for the info Ashley. That being the case "know bug", would it be heresy to suggest altering The Rotary competition? With regard to mandatory use of 'Rotate layout' and 'Rotate layer'. To allow entries that clearly use Rotation as the core Design mechanic. Even if Rotate layout/Rotate layer are not the actions used to facilitate it?   

Apologies, I know those are loaded questions.
B
83
S
12
G
9
Posts: 99
Reputation: 9,478

Post » Sun Feb 19, 2012 10:33 pm

I agree with onzephyr, I'm stuck because of the weirdness of the layer rotation, however I need different objects to follow or not that rotation (so I can't use layout rotation)
B
22
S
3
G
6
Posts: 59
Reputation: 4,450

Post » Mon Feb 20, 2012 2:20 am

We could always use a time extension ;)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Mon Feb 20, 2012 12:46 pm

Indeed, I saw many people using layer rotation instead of a simple
[code]set X to centerX + cos(angle) * distance(cx,cy,sprite.x,sprite.y)
set Y to centerY + sin(angle) * distance(cx,cy,sprite.x,sprite.y)[/code]

Which will really rotate the object (making the collision follow) and you also give control over the center of rotation. With layer rotation you don't have that control.
Moreover, now that family is on the rail, grouping object to rotate them is a piece of cake. Using Layers to do that also force objects to be in the same kind of zSorting group (we can imagine a game with some complex layering of object regardless of either or not they rotate...)
Anyway, this unfortunately leads to bad programming design like rotating object and creating collision object on another layer and rotating them with the aforementionned formulat just to be in the contest rules.

However, as the associated rule of the rotary contest is "Every game must make use of the system 'Rotate layer' or 'Rotate layout' actions. It must be an important feature of the gameplay and not just added on as an afterthought."

And I think changing it "To allow entries that clearly use Rotation as the core Design mechanic. Even if Rotate layout/Rotate layer are not the actions used to facilitate it?" might arm some entries (for now... maybe just mine :D)
'cause rotation being the "core mechanic" wasn't in the rule. The rule just stated that rotation should be "an important feature" and shouldn't be "added on as an afterthought" so there's a wide range of possibility between "core mechanic" and afterthought.
(in my case layout rotation appears at level 6 and had a level of freedom in the maze)

So if I might suggest something it would be "Every game must make of use or mimic the system 'Rotate layer' or 'Rotate layout' actions. It must be an important feature of the gameplay and not just added on as an afterthought."

But I would also add that changing a core rule one week before the end might not be fair to some people (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Feb 20, 2012 1:07 pm

[QUOTE=Yann] Indeed, I saw many people using layer rotation instead of a simple
[code]set X to centerX + cos(angle) * distance(cx,cy,sprite.x,sprite.y)
set Y to centerY + sin(angle) * distance(cx,cy,sprite.x,sprite.y)[/code][/QUOTE]

...simple answer - "No programming required!", or not everyone is such a math wiz like you
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Mon Feb 20, 2012 1:47 pm

Well... In my opinion, using condition and action is already programming... so I don't really agree with the "No programming required!".
But I'm ok with scirra using that little twist (it's more no scripting language required) 'cause it probably helps breaking some barriers people automatically puts in there mind when they read the scary word "program"

Also math isn't programming, programming can use math, but both aren't the same.

And, using that kind of argument isn't really open minded.

And finally, the formula I used, you learn it in highschool, in a disguised way yes, but you learn it. It's not super advanced math.Yann2012-02-20 13:47:57
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to How do I....?

Who is online

Users browsing this forum: plinkie and 18 guests