• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by NeonTheCoder · Jan 13, 2020 at 10:37 AM · collisionphysicsdots

Unity.Physics Pure ECS/DOTS Implementation Causes Transforms.Translation to error into NaN

Trying out the new ECS and Physics system and I seem to run into an error, or bug of some sort.

Using this page as a guide Introduction to Unity Physics I tried to take a simple moving cube and have them collide with each other.

However, for some reason even though the Component Data is the same with these cubes, and a GameObject to entity conversion they do not appear in the scene. Digging further I found the cause to be that the Translation component's value is NAN. To be more accurate the Translation goes from the value I set, to float3.zero, to NaN.

Here is my implementation: ```

     EntityManager eM = World.Active.EntityManager;
     EntityArchetype Test = eM.CreateArchetype(
         typeof(RenderMesh),
         typeof(LocalToWorld),
         typeof(Translation),
         typeof(Rotation),
         typeof(Unity.Physics.PhysicsCollider),
         typeof(Unity.Physics.PhysicsDamping),
         typeof(Unity.Physics.PhysicsVelocity),
         typeof(Unity.Physics.PhysicsMass)
     );

     NativeArray<Entity> EA = new NativeArray<Entity>(1, Allocator.Temp);
     eM.CreateEntity(Test, EA);

     for(int i = 0; i < EA.Length; i++) {
         Entity e = EA[i];
         eM.SetComponentData(e, new Unity.Physics.PhysicsCollider { Value = Unity.Physics.BoxCollider.Create(new Unity.Physics.BoxGeometry() { Center = float3.zero, Orientation = quaternion.identity, Size = new float3(1, 1, 1) }, Unity.Physics.CollisionFilter.Default)});
         eM.SetComponentData(e, Unity.Physics.PhysicsMass.CreateDynamic(new Unity.Physics.MassProperties(), 10));
         eM.SetComponentData(e, new Unity.Physics.PhysicsVelocity() { Linear = new float3(0.1f, 0.1f, 0.1f), Angular = new float3(0.1f, 0.1f, 0.1f) });
         eM.SetComponentData(e, new Unity.Physics.PhysicsDamping() { Linear = 0.01f, Angular = 0.05f });

         eM.SetSharedComponentData(e, new RenderMesh {
             mesh = Mesh,
             material = Material
         });
     }

     EA.Dispose();```


I'm not sure what went wrong here, as this seems to work according to the Unity Manual.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CaseyHofland · Jan 12, 2020 at 12:48 PM 0
Share

For the love of god do this:

 some code
 
 
 
 here's some more
Show more comments
avatar image Kmsxkuse · Jan 25, 2020 at 10:14 PM 0
Share

I've had a similar problem described here: https://forum.unity.com/threads/entity-disappearing-yet-another-difference-between-rigidbody-and-dots.815640/

No solution unfortunately.

avatar image BenJoe72 · Apr 07, 2020 at 06:46 AM 0
Share

Any luck with finding an answer? I'm having the same problem. Even tried to copy all the data from a converted object and still nothing. It seems that the PhysicsVelocity is what messes up everything. If I only add the PhysicsCollider, Physics$$anonymous$$ass, PhysicsDamping, the entity still gets rendered, but as soon as I add PhysicsVelocity, all the position data goes to NaN.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by smirk · Apr 24, 2020 at 04:30 PM

 BlobAssetReference<Unity.Physics.Collider> spCollider =
     Unity.Physics.SphereCollider.Create(new SphereGeometry{Center = 0, Radius = 1});
 Unity.Physics.Collider* colliderPtr = 
     Unity.Physics.Collider*)spCollider.GetUnsafePtr();
 entityManager.AddComponentData<PhysicsMass>(
    entity, 
    PhysicsMass.CreateDynamic(colliderPtr->MassProperties, 4)
 );
 entityManager.AddComponentData<PhysicsCollider>(
    entity, new PhysicsCollider{Value = spCollider}
 );

I had the same problem and could only fix it using unsafe pointers. Here is the source where I found that example: Creating bodies from scratch But I am not sure if this is a real fix since you will need to enable unsafe mode in player settings.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Berzerkeer · May 20, 2020 at 11:10 AM

Facing the same issue and the solution won't work for me. Funny thing is that just by adding the PhysicsVelocity component the entity goes straight to NaN hell with all its translation, rotation and LocalToWorld values.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

222 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Changing mesh collider's mesh cause objects go into mesh. 1 Answer

How can I do collision detection using Unity Physics (preview) in DOTS workflow? 0 Answers

Unity2D Collision is bugged 0 Answers

I want collision boxes to be precise without overlapping each other 1 Answer

is there a way to move a rigidbody with something like moveposition without clipping through collider? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges