How to move a non INFINITE MASS body?
- zaldzbugz
- Posts: 38
- Joined: Tue Jan 19, 2010 2:45 am
- Contact:
How to move a non INFINITE MASS body?
Hi, do you have an idea how to move a body with a non-infinite mass. I tried moving some body but it only works with body of infinite masses.
I need your help.
Regards,
ZaldzBugz
I need your help.
Regards,
ZaldzBugz
[color=#400000][i]"A man of tomorrow is forged by his battles today."[/i][/color]
- Tam Toucan
- Posts: 141
- Joined: Tue Jun 23, 2009 4:26 pm
- Contact:
Re: How to move a non INFINITE MASS body?
Erm what exactly is the problem? The entire documentation and examples all deal with non-infinite masses. In fact I've never thought about trying to more something with infinite mass.
- zaldzbugz
- Posts: 38
- Joined: Tue Jan 19, 2010 2:45 am
- Contact:
Re: How to move a non INFINITE MASS body?
i wanted to try moving objects with non-Infinite masses using various animations or actions. Like MoveTo, MoveBy, JumpTo etc.
[color=#400000][i]"A man of tomorrow is forged by his battles today."[/i][/color]
- Tam Toucan
- Posts: 141
- Joined: Tue Jun 23, 2009 4:26 pm
- Contact:
Re: How to move a non INFINITE MASS body?
Still not clear what you mean. Do you mean move as in directly change the position, not by applying forces? Or do you want to write a "jumpTo" function that works out the forces to apply to an object to make it jump to a given location?
- zaldzbugz
- Posts: 38
- Joined: Tue Jan 19, 2010 2:45 am
- Contact:
Re: How to move a non INFINITE MASS body?
Yes, i want to use JumpTo to apply forces to an object to make it jumpto a given position. And this object has non-infinite mass.
[color=#400000][i]"A man of tomorrow is forged by his battles today."[/i][/color]
- Tam Toucan
- Posts: 141
- Joined: Tue Jun 23, 2009 4:26 pm
- Contact:
Re: How to move a non INFINITE MASS body?
Well there's not a nice easy general "do this" solution. For simple movement you could try cpBodySlew. JumpTo is harder. Normally you would have a fixed jump, not a "jump from here to there" (where the 'there' can be anywhere relative to 'here'). Do you really need that? Can you not have a few fixed jumps? i.e. you have different impulses that "throw" the object in desired arcs.
Couple of ideas. Hopefully someone who's tried this will have some better help
1) Look at this thread. Think of the jump as trying to fire a ball from the current point to the desired point.
2) Somehow calculate a curve from the 'here' to 'there' and use cpBodySlew to move towards a set of points along it's path.i.e. pick (say) 5 points on the curve and move towards the first, once near move towards the next etc. I suspect it would be very hard to stop jerky/angular movement
3) It might be possible to use constraints. Look at how the grab with mouse code works (I'm sure the demos have some, also there is this. Now imagine setting the point you want to jumpTo as the mouse position. The object will be pulled towards it (in a straight line). Now by adjusting the velocity you should be able to get a curve.
Couple of ideas. Hopefully someone who's tried this will have some better help
1) Look at this thread. Think of the jump as trying to fire a ball from the current point to the desired point.
2) Somehow calculate a curve from the 'here' to 'there' and use cpBodySlew to move towards a set of points along it's path.i.e. pick (say) 5 points on the curve and move towards the first, once near move towards the next etc. I suspect it would be very hard to stop jerky/angular movement
3) It might be possible to use constraints. Look at how the grab with mouse code works (I'm sure the demos have some, also there is this. Now imagine setting the point you want to jumpTo as the mouse position. The object will be pulled towards it (in a straight line). Now by adjusting the velocity you should be able to get a curve.
- zaldzbugz
- Posts: 38
- Joined: Tue Jan 19, 2010 2:45 am
- Contact:
Re: How to move a non INFINITE MASS body?
great Tam..thanks
[color=#400000][i]"A man of tomorrow is forged by his battles today."[/i][/color]
- zaldzbugz
- Posts: 38
- Joined: Tue Jan 19, 2010 2:45 am
- Contact:
Re: How to move a non INFINITE MASS body?
Hi again. i have an INFINITE mass object that is added to a layer in which this layer is moving. is there a way that this INFINITE mass object will also move relative the layer where it was added? I tried but the only one that is moving is the shape->data on an object as sprite and not including the body.
[color=#400000][i]"A man of tomorrow is forged by his battles today."[/i][/color]
- Tam Toucan
- Posts: 141
- Joined: Tue Jun 23, 2009 4:26 pm
- Contact:
Re: How to move a non INFINITE MASS body?
Sorry you'll have to rephrase that. Layers don't move. Layers in Chipmunk are the term used for the cpBody.layers member which defines which other layers the shape will collide with See the wiki here.
-
- Posts: 90
- Joined: Tue Aug 04, 2009 9:53 am
- Contact:
Re: How to move a non INFINITE MASS body?
It sounds like he means layer in the Cocos2d sense.... why don't you just match up your chipmunk coordinates with the layers coordinates... in other words make your chipmunk coordinates be relative to your layer's anchor/position, then it won't matter if your layer is moving or not as its all relative.
Who is online
Users browsing this forum: Heise IT-Markt [Crawler] and 10 guests