Phizix - keep two objects together
In the Phizix chipmunk engine I want to keep two objects together with relative points so that they are completely melted to eachother.
It's hard to explain, but I kinda want this effect:
http://img178.imageshack.us/img178/3592/royale1aq1.png
That no matter what angle they're at, they're still positioned relatively to eachother, and both work with the collision.
Re: Phizix - keep two objects together
Attach a pin joint between their centers... Or add them both to the same body i you want to lock their relative rotation as well.
Re: Phizix - keep two objects together
Quote:
Originally Posted by Werbad
Or add them both to the same body i you want to lock their relative rotation as well.
Silly of me not thinking of that!
But how do I keep their relative positions?
Re: Phizix - keep two objects together
Set the hotspot of both objects to the center of the merged body
Re: Phizix - keep two objects together
But there's no way to set the hotspot during runtime am I right?
Also, if I did this method of yours, would the blocks still keep their individual collision?
Re: Phizix - keep two objects together
You have two options here.
If you want the two cubes to be represented via a single physical body and attach two actives to it without having to set their hotspot positions to the center of the physical body, you'll have to create your own manual positioning events, rather than using the 'attach active' features that Phizix provides.
The second option is to create two pivot joints between the bodies. The pivot points of the two joints should set to the positions of each of the bodies. This will lock the angles of the objects to each other as well.
Both methods has it's advantages and disadvantages. The first one is definitely a bit more clean, but it can potentially be more complicated (at least the part about figuring out how to position the cube objects from the event editor).
Re: Phizix - keep two objects together
Quote:
Originally Posted by Nifflas
The second option is to create two pivot joints between the bodies.
This one worked beautifully :D
Re: Phizix - keep two objects together
A new question, is there any way to completely freeze an object's X or Y position? Whenever I use "always set X/Y position" or "on loop set X/Y position", if you hit the object with another object really hard it still bounces. Is there any way to freeze these positions completely?
(also when I set the positions I also set the velocity to 0)
Re: Phizix - keep two objects together
Remove and recreate it as a static object.
Re: Phizix - keep two objects together
There's another method to lock an object's X and Y position without locking the angle or angular speed. I always keep a static body (which I call the 'lock body') in the game that is removed from all collision layers. To lock the x/y positions of an object, just create a pivot joint from from the 'lock body' to your object. The position of the pivot point should be the same as the object you're locking.
Werbad's solution should be used to completely freeze your object including it's angle. Your object will also lose all it's connected joints with this method.
My solution should be used when you only want to freeze the position, but not it's angular speed.