#How can I work with script with ConfigurableJoint in DOTS?
1 messages · Page 1 of 1 (latest)
if you open the entity inspector and set to runtime, it should show what the baking results in. the rigidbody for each bone should be in worldspace, and parented to it should be the joint entities with the PhysicsJoint and PhysicsConstrainedBodyPair under the rigidbody
sorry entities hierarchy, not inspector
Hi Baron! I appreciate the reply! Not sure if I undestand.
However I just created a GameObject in the subscene, then added a ConfigurableJoint, and in the Runtime it doesn't show PhysicsJoint or PhysicsConstrainedBodyPair.
And did you mean that all the Entities with joints should be in the worldspace for me to be able to access their PhysicsJoint?
the joint doesnt appear connected to anything in your second post
I connected it, however it still doesn't show. What could I be missing Baron?
just tried this, configurable doesnt appear to be baking for me which might be the issue
For me doesn't bake either
Thank you for trying Baron
change the xmotion to something other than free, does it change the baking result(think it should)?
If you mean this, it didn't work
odd, worked on my end. anyway theres a note in the changelog about this https://docs.unity3d.com/Packages/com.unity.physics@1.3/changelog/CHANGELOG.html#fixed-15 ConfigurableJoint baking won't create empty UnityJoint (with no constraints) for unlocked linear and angular degrees of freedom
This is so strange, it's not working for me
Do you think it could be the Unity verison Baron?
I'm using 6000.0.32f1
screenshot of entities hierarchy?
or select the child of that entity
so PhysicsJoint and the constrained component arent added to the originating entity that is the rigidbody, its another separate entity
Should it be during Runtime?
Mine seems to be missing things from yours
I think I'm starting to understand what you mean
yeah set both to runtime
Oh wait
Found it
So, the PhysicsJoint will be a child Entity of an Entity? @mystic trellis
yeah
I was trying to do this Query:
foreach ((RefRO<SyncPhysicsJointComponent> syncPhysicsJointComponent,
RefRW<PhysicsJoint> physicsJoint)
in SystemAPI.Query<
RefRO<SyncPhysicsJointComponent>,
RefRW<PhysicsJoint>>())
However the PhysicsJoint won't be in the same Entity. Do you know a way I could do this?
just guessing but a bakingsystem to find entities with the PhysicsConstrainedBodyPair and using that you could find the rigidbody entity, and add any extra components for your runtime system to act on. I havent ever modified joint data at runtime so not familiar with the process
Alright, I appreciate all the help Baron
Gonna study a bit
good luck 🙂
Thank you haha
I'm having no luck. If someone knows how to get the reference for the PhysicsJoint I would appreciate a lot xD
show current attempt
I'm studying how to create PhysicsJoints through script, however if there is an easier way to just get the PhysicsJoints that Unity creates when I add a ConfigurableJoint, it would be easier.
What if I create a Tag named "SetPhysicsJointsReference", then I have a System that will constantly Query for that Tag, so when a Character is instantiated, it will search for the PhysicsJoints in the child Entity and set the reference, after is done, it will remove the Tag. Would that be efficient?
I think it would be easier to just create PhysicsJoint through script...
So I had this idea. I added the ConfigurableJoint in some Entities, so Unity will create 2 entities as a child with PhysicsJoints, I then created a PostBaking System, and in it I put a Debug to check how many childs entities there were inside these Components, and it shows 0, even though I can clearly see them in the Entities Hierarchy, here is the code below and the images
using System.Diagnostics;
using Unity.Burst;
using Unity.Entities;
using Unity.Physics;
using Unity.Transforms;
using static SyncPhysicsJointAuthoring;
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
[UpdateInGroup(typeof(PostBakingSystemGroup))]
partial struct SyncPhysicsJointBakingSystem : ISystem
{
//[BurstCompile]
public void OnUpdate(ref SystemState state)
{
foreach (RefRW<SyncPhysicsJointComponent> syncJoint in SystemAPI.Query<RefRW<SyncPhysicsJointComponent>>())
{
Entity mainEntity = syncJoint.ValueRO.thisEntity;
UnityEngine.Debug.Log($"Entity {mainEntity} has Child: {state.EntityManager.HasComponent<Child>(mainEntity)}");
if (state.EntityManager.HasComponent<Child>(mainEntity))
{
DynamicBuffer<Child> childBuffer = state.EntityManager.GetBuffer<Child>(mainEntity);
int jointCount = 0;
UnityEngine.Debug.Log($"Checking entity: {mainEntity}");
}
}
}
}