playMaker

Author Topic: Adding / Activating fixed joint on collision trigger  (Read 2348 times)

daniellogin

  • Full Member
  • ***
  • Posts: 215
Adding / Activating fixed joint on collision trigger
« on: March 11, 2018, 01:32:08 AM »
Basically I want a custom toy maker in a VR game. I want to have various heads, arms, legs, etc. They will be picked up and touched onto a torso to fix in place.

I can't figure out how to do this.

Too bad the Fixed Joint component can't be enabled or disabled or that would be way easy. So is there a way that a collision can trigger it to be added or something to that effect?

I can't just store the collision and use that as the fixed joint Connected Body property. First of all, the gameobject can't move if you start it with a fixed joint and no connected body specified. As a less desirable option, I could have the torso frozen before connection, but I still can't specify what to connect with on collision. The collision can store a Game Object, but the Set Property action can only specify an Object as the variable to use as the Connected Body in the fixed joint.

Maybe I need to set the rigid body I want as the variable, but how do I do that?

Or maybe someone has a better idea on how I can get various parts to snap together on touch?

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Adding / Activating fixed joint on collision trigger
« Reply #1 on: March 11, 2018, 03:58:46 AM »
Ok, well I found a not great but working way to do it.

* The torso adds a fixed joint to it's self with an FSM and identifies it with a global var. It is frozen and cannot move as a result.
*  The body parts to attach have their rigid bodys added in their FSMs, and are thus able to be identified by local vars
* The body parts watch for a collision with the torso, then set the property of the torso's fixed joint (via the global var) to it's local rigidbody var

I guess I could stop the torso from being frozen before this happens by only adding the fixed joint after a collision or something. 

I would still like to know if there is a way to identify a component of another gameobject without having to create the component first.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Adding / Activating fixed joint on collision trigger
« Reply #2 on: March 11, 2018, 11:16:09 AM »
Hi.
You can use 'Get Component' to get a certain component on you gameobject.

i am not sure what you are making, but maybe you can try a different approach.

Have a complete version with everything connected.
Then disable the parts (arms,Legs,Head)

then have part lying around.

When a part is dragged to the complete version do the connect animation and then disable the part dragged on it and enable that part on the Complete version.

If you need to change the mesh, you can use 'Set Mesh' which you can find on the Ecosystem

or change material if only the material need to be changed

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Adding / Activating fixed joint on collision trigger
« Reply #3 on: March 11, 2018, 11:46:54 AM »
Hi.
You can use 'Get Component' to get a certain component on you gameobject.

i am not sure what you are making, but maybe you can try a different approach.

Have a complete version with everything connected.
Then disable the parts (arms,Legs,Head)

then have part lying around.

When a part is dragged to the complete version do the connect animation and then disable the part dragged on it and enable that part on the Complete version.

If you need to change the mesh, you can use 'Set Mesh' which you can find on the Ecosystem

or change material if only the material need to be changed
Thanks for the tips. I was trying to do the Get Component but was stuck on how to actually identify the right component. Without it in front of me though I can't say what wasn't working.

As for using a complete thing with parts disabled, that did cross my mind. In facts it's the system I used for something else, although that only had 3 possible outcomes. This one is for a toy where there may be like 4 different heads, 4 different arms, etc etc. Too many combinations for me to be bothered to pre-make. I also wanted it to be more flexible so maybe a head could be used a leg or something silly like that.

I think I have it sorted now by basically creating the joints as they are needed, and thereby also having a way to create it's identification at the same time.