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 / Using prismaticjoint to approach two sprites

Author
Message
BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 6th Mar 2012 09:48
Hi all,
I'm trying to use a prismaticjoint to hold together two objects which may be separated but then again approaching.
The problem is I do not know how to do that when they are approaching, stop at a certain distance.
To create the joint do this:

createprismaticjoint (1, SPR1, spr2, getspritex (SPR1) +30, getspritey (SPR1) +30, 0.1,0, 1)

Please, someone knows what should be included to stop bringing the two sprites when, for example, 80 pixels away?

Thank you very much.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Mar 2012 10:57
You could, once you know they are within 80 pixels, reposition them the right distance apart:


BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 6th Mar 2012 11:01
Thanks, Bax.
I'll try this evening and tell if it works for me!
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 6th Mar 2012 17:21
You can use the command SetJointLimitOn() with the lower and upper bounds being multiples of the vector specified when creating the joint. For example in your case a limit to 0.5 to 1 would allow movement along the X axis between 0.05 and 0.1 units which is half the vector length to the full vector length.
BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 6th Mar 2012 19:39
Hi all,
I've tried both methods and works well!
Using jointlimits the movements is smoother.

Thanks for your help Baxslash and Paul.
Regards.

Login to post a reply

Server time is: 2024-05-07 11:53:31
Your offset time is: 2024-05-07 11:53:31