[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Move Object (Body) to Location

Move Object (Body) to Location

Official forum for the .

Move Object (Body) to Location

Postby mypi » Thu Aug 18, 2011 7:34 am

mypi
 
Posts: 1
Joined: Thu Aug 18, 2011 7:09 am

Re: Move Object (Body) to Location

Postby Bobramyl » Fri Aug 19, 2011 1:47 pm

Bobramyl
 
Posts: 16
Joined: Sun Nov 07, 2010 3:02 pm

Re: Move Object (Body) to Location

Postby slembcke » Fri Aug 19, 2011 3:23 pm

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Move Object (Body) to Location

Postby markhula » Sun Aug 21, 2011 7:57 am

Hey Scott,

I thought "teleporting" was bad; and certainly shouldn't be done on many objects on a per frame basis???

Cheers

Mark
markhula
 
Posts: 188
Joined: Wed Feb 02, 2011 4:23 am

Re: Move Object (Body) to Location

Postby slembcke » Sun Aug 21, 2011 12:43 pm

Teleporting is generally fine as long as you only do it once in a while. You probably want to be careful that you don't teleport it into a wall or another object.

Changing the position every frame is bad because it doesn't allow the physics to do what it's supposed to. Setting the velocity explicitly each frame like velocity = constantValue is also sort of bad.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Move Object (Body) to Location

Postby usandhar » Mon Jun 17, 2013 11:33 pm

Hi Guys - Are there any updates to "how to smoothly move the object over time to a touched point", especially, if I were doing it using Obj-Chipmunk? Thanks for your help.
usandhar
 
Posts: 18
Joined: Thu Jun 13, 2013 4:56 pm

Re: Move Object (Body) to Location

Postby slembcke » Tue Jun 18, 2013 9:13 am

Yes, there are many ways to do it. Use force to accelerate the object over time, make small velocity changes over time, use a constraint to do it. You don't need to change the position of an object explicitly or constantly overwrite the velocity of an object to do that.

I usually pick the last way, and that is described in the the following tutorial:
http://chipmunk-physics.net/tutorials/ChipmunkTileDemo/
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Move Object (Body) to Location

Postby usandhar » Tue Jun 18, 2013 3:53 pm

Thanks Scott. I tried it and it works great. Two follow-up Qs:
1) How can I remove ChipmunkPivotJoint to several ChipmunkBody objects? I tried [targetPointBody removeFromSpace: space] but that doesn't work. Think of this as balloons getting attracted to touch but as soon as the touch is removed they start falling to the ground.

2) How can I have different ChipmunkBody objects move smoothly towards touch point and stop at different lengths from the touch point as opposed to all ChipmunkBody objects trying to get as close as possible to the touch point?

Thanks in advance for your help.
usandhar
 
Posts: 18
Joined: Thu Jun 13, 2013 4:56 pm

Re: Move Object (Body) to Location

Postby slembcke » Tue Jun 18, 2013 4:15 pm

First of all, you should use the [ChipmunkSpace add:] and [ChipmunkSpace remove:] methods for adding and removing everything. You can use the more specific methods, but those really only exist to implement the ChipmunkBaseObject protocol (which you don't really need to care about).

If you want to remove multiple objects at once, you need to create an object that implements the ChipmunkObject protocol. All it needs is a chipmunkObjects method or property that holds an array of all the things to add or remove.

If you don't want all of the objects to converge on the same point, then just make a separate joint for each and give them different coordinates.

Also, the forces produced by constraints might look weird for a balloon. A simple force that pushes the balloon towards the point and a drag force to keep it from moving too fast might work better.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Move Object (Body) to Location

Postby usandhar » Tue Jun 18, 2013 9:10 pm

Thanks Scott. Do you have an example of ChipmunkBaseObject protocol? I added separate joint for each bodies and converge bodies to their respective point on touch. Right now, I converge all joints to the same point (although I will change this soon to go to different co-ordinates). On touchesbegan, I add the target points and joints and reposition. On touchmoved, I move all target points and on touchended I remove all touch points and joints so the bodies can free fall or float around. When I touch the screen for the first time it works well - the bodies converge well and when I let go the touch the bodies fall down due to gravity setting. However, when I retouch the converge doesn't work as well. Could you please point me to what might be going wrong?

Thanks.
usandhar
 
Posts: 18
Joined: Thu Jun 13, 2013 4:56 pm

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest