Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suggestion / Idea  [Workaround] Setting target at runtime for ObiParticleAttachment
#1
Bombilla 
Made a thread awhile back regarding this issue here.

I havent fully tested this workaround but since my current project has networking and players have "body parts" that are ropes it requires me to spawn them on player creation for those ropes to sync across the network. Once instantiated then I have to assign the "target" variable from the ropes ObiParticleAttachment component and found out if you assign the ropes game object position to where you want it then set the target variable attachment without it being under a solver (as a child) and then reparent it to the solver (so it can simulate) it keeps its position you assigned originally without it doing what you can see in the old thread.


Code:
private void SpawnBodyPart(GameObject bodyGO)
   {
       // Instantiate locally then on server for all clients
       var goInstance = Instantiate(bodyGO, transform.position, bodyGO.transform.rotation);
       NetworkServer.Spawn(goInstance);

       // Assign target attachment to player
       var attachment = goInstance.GetComponent<ObiParticleAttachment>();
       attachment.target = transform;
       
       // Reparent to main solver
       var solver = GameObject.FindGameObjectWithTag("ObiSolver");
       goInstance.transform.SetParent(solver.transform);
   }

Thats on creation, there some other functions I will be testing and one of the main ones is having player pick up items which is very easy to do with ObiRope. Once the rope end reaches the item ill try this workaround to see if I can attach the ropes (arm) end to the item object. I really like the new pin/attachment system in Obi5 for the dynamic 2 way physics and will probably have to attach quite a bit at runtime.

I just wanted to bring this up because I think attaching at runtime would be a nice feature.

Ill update this if attaching with the other functions work.
Reply


Messages In This Thread
[Workaround] Setting target at runtime for ObiParticleAttachment - by VirtualCucumber - 11-03-2020, 10:30 PM