Box2D Forums

It is currently Wed May 22, 2013 4:32 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed Jun 22, 2011 1:19 am 
Offline

Joined: Wed Jun 22, 2011 1:12 am
Posts: 6
Location: Canada
Hi everybody,
So I have slight issue at hand. Basically, I have a system of BodyShapes, connected by revolute joints. Works great, etc etc. The tough part, is I need the shape on the end of the system to follow the mouse as if it was being dragged, but it would actually just be constantly at the mouse's x and y. I attempted to use some simple AS to make the piece follow the mouse, but in what I've tried the end piece of the system detaches in order to follow the mouse, every time.

Any input is greatly appreciated, thanks!


Top
 Profile  
 
PostPosted: Wed Jun 22, 2011 11:30 am 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
Ok so it sounds like you've got the body following the mouse, right? That works? So the problem is the joint detaches? What if you have that body NOT follow the mouse? Does the joint work then?


Top
 Profile  
 
PostPosted: Wed Jun 22, 2011 10:08 pm 
Offline

Joined: Wed Jun 22, 2011 1:12 am
Posts: 6
Location: Canada
Yup, when I drag the end peice all the joints work perfectly, its just whenever the follow mouse thing is attempted it detaches.


Top
 Profile  
 
PostPosted: Wed Jun 22, 2011 11:43 pm 
Online

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
It sounds like you are teleporting (SetTransform) the head of the chain to the mouse position, and the rest of the chain cannot catch up, because the movement takes time to propagate along the chain. This is quite realistic, if you had a chain in real life and you pull one end, the other end doesn't automatically start moving immediately.

Unfortunately it's kinda hard to do what you're trying to do. One way would be to use a mouse joint but you probably don't want the springy sagging down behavior that causes. Another way might be to look at the difference between the mouse position and the head of the chain, then set the velocity of the head link to move in that direction, but limit the max speed it can go at. This would still take a few timesteps to get to the mouse position but it would not be springy and the chain should hold together better. If you dont need the head link to rotate realistically you could also experiment with making the head link a kinematic body for the duration of the drag.


Top
 Profile  
 
PostPosted: Fri Jun 24, 2011 1:30 pm 
Offline

Joined: Wed Jun 22, 2011 1:12 am
Posts: 6
Location: Canada
Hmm, would it work if I just programmed the end piece to move towards the mouse, and made it an animated body?


Top
 Profile  
 
PostPosted: Fri Jul 08, 2011 6:05 pm 
Offline

Joined: Wed Jun 22, 2011 1:12 am
Posts: 6
Location: Canada
Don't mean to bump, but is it possible to have a kinematic body being propelled by like... .x and .y movement? While staying attached to the system, the issue is still unsolved unfortunately


Top
 Profile  
 
PostPosted: Fri Jul 08, 2011 9:56 pm 
Online

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
Sure, you can set the location and velocity of a kinematic body - but if you move it really fast you'll still have the problem of the other segments needing time to catch up.
I suppose you could join the head of the chain to every other segment of it with rope joints so that each segment could catch up quicker to where the head was going instead of waiting for the movement to propagate down the chain.


Top
 Profile  
 
PostPosted: Sat Jul 09, 2011 6:25 am 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
HypnoFish wrote:
Don't mean to bump, but is it possible to have a kinematic body being propelled by like... .x and .y movement? While staying attached to the system, the issue is still unsolved unfortunately

If you set the type to "Animated" then you can set the x and y of the body manually.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group