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!
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?
Yup, when I drag the end peice all the joints work perfectly, its just whenever the follow mouse thing is attempted it detaches.
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.
Hmm, would it work if I just programmed the end piece to move towards the mouse, and made it an animated body?
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
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.