Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Physics2D joints

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 6th May 2020 16:05 Edited at: 6th May 2020 16:19
Hi,
I am play with the physics2D of AppGameKit lately.
I try to learn how the joints works. I created a prismatic joint If I prevent the rotation of one sprite of the joint, using the command

then the command

has no effect.
Is it possible to create a prismatic joint but restrict the rotation of the whole body?

EDIT: I uploaded the project

Attachments

Login to view attachments
Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th May 2020 19:41 Edited at: 6th May 2020 20:46
george++,

Quote: "Is it possible to create a prismatic joint but restrict the rotation of the whole body?"

+
Quote: "The prismatic joint allows the sprites to only move along a given axis relative to each other."

= the angle between the 2 sprites should always = atanfull(x2# - x1#, y2# - y1#). you can't get any more restrictive than that


otherwise, i think you're misunderstanding the parameters of the prismatic joint:

IE, i don't understand your use of GetSpriteXByOffset(spr2), GetSpriteYByOffset(spr2) for vx, vy where those params represent which axes (relative to the angle between the 2 sprites) that the sprites can move along (x &/or y).

so, 0 or 1 for each parameter/axis (<< it might not be as simple as that. i haven't explored other values). add again: (it's the vector. i get it now...)

you're doing similar with the x, y params using GetSpriteXByOffset(spr1), GetSpriteYByOffset(spr1) as the joint's anchor point (vs, perhaps, the center-point between the 2 sprites that i might have expected?) .

i just realized, you want spr2 to rotate around spr1? (where you have set x, y properly, if that's the case)

so, questions:

do you want the joint to be centered between the 2 sprites?

do you want them to stay within a certain range of eachother?

do you want the joint/center-point to be able to rotate (and be limited?) ?

do you want the sprites to be able to rotate independently from each other (and be limited) ?

the short version: can you better describe your desired effect?
Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th May 2020 20:31 Edited at: 6th May 2020 20:48
btw, i've taken some time off from work recently and have spent some of that digging into all things box2d.

from that:

Prismatic Joint
Quote: "
A prismatic joint allows for relative translation of two bodies along a specified axis. A prismatic joint prevents relative rotation. Therefore, a prismatic joint has a single degree of freedom."


the small % of what i've retained thus far has shed some light on AGK's implementation of box2d (including the fact that AppGameKit has implemented a seemingly-random scale of 0.2).

as i'm still sorting things out in my head, i've been shying away from such things as this recent Q re: Range of Forces where the answer isn't so simple.
Quote: "The value we give represents pixels or units?"

= neither, directly.

meanwhile, i've updated the previous response re: vx, vy... sorry to have this stuff spill/trickle out ass happen

i need to "step away"... maybe even go back to work! heh
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 6th May 2020 21:10
Thank you for these detailed indormation. It is true that I didn't understand exactly the parametres of the creation of the joint.
Quote: "do you want them to stay within a certain range of eachother?"

Yes, but without any rotation. What I need is to create a platform. The platform consisting of two or more pieces. I need to create a joint between these pieces ,but set the velocity only to one of them.
So far I was able to create the platform using kinematik objects and controling their velocity one by one. I thought that it would be more efficient, if I create a joint and move only one object of them.

Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th May 2020 23:13 Edited at: 6th May 2020 23:18
Quote: "Yes, but without any rotation."

i think i get it.

try keeping the primary piece as kinematic and make any other sprites/pieces that you want to attach to the primary as dynamic and attach them with a weld joint.

by the way, your background graphics are gorgeous. even more so if those lanterns swayed with the breeze
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 7th May 2020 05:04 Edited at: 7th May 2020 05:33
Thank you for the tip. I'll try it
Quote: "by the way, your background graphics are gorgeous. even more so if those lanterns swayed with the breeze"

Indeed. I downloaded it from craftpix.net. It is in .ai format also. A digital artist could animate the lanterns with ease...

Login to post a reply

Server time is: 2024-11-25 06:06:27
Your offset time is: 2024-11-25 06:06:27