A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by blackbird_dream » Tue Dec 12, 2017 5:35 am
Hi,
I've tried to set up a vehicle model based on raycasting for the wheel/ground interactions.
As the Raycast functionalities of Newton Dynamics are not yet implemented in Unity I tried using Physics Raycasting functions but it does not work as can be seen below.
here a basic example showing 4 wheels released from a height. The reaction force is proportional to the deflection which is calculated from the NewtonBody position and the damping force proportional to the NewtonBody velocity (F=k*x-C*v)
with:
- Code: Select all
x=0.32f-body.Position.y;
x= Mathf.Max(x,0);
https://youtu.be/9pJGNfsExeQThe test is stable
here is an equivalent example built with Unity Raycasting to determine the deflection.
- Code: Select all
if (Physics.Raycast(transform.position, Vector3.down, out hit)) { x= hit.distance; }
x = 0.32f - x;
x= Mathf.Max(x,0);
This test is unstable:
https://youtu.be/GcWhm-NZw_EThe same test with one body instead of 4 was stabler although it is prone to divergence in function of the refreshing rate :
https://youtu.be/-f3KLaXEBGUAs conclusion, I'm stuck with this problem of Raycasting
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by Julio Jerez » Tue Dec 12, 2017 9:21 am
just one more week and we will resume the Unity plug in to bring up to date.
the firs thing we will add is the Raycast functionality.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by S. Darkwell » Sun Jan 07, 2018 10:13 pm
Julio, I am also interested in this.
Last I heard, you said that you would implement it on the weekend following July 17th, 2017.
Thank you for being willing to implement it!
- S.
-
S. Darkwell
-
- Posts: 8
- Joined: Thu Jul 13, 2017 5:50 pm
-
by Julio Jerez » Sun Jan 07, 2018 10:55 pm
yes and I apologize for that, I though I was going to the to the last thing by teh end of the year but I could not.
I am very close thought, and I will be ready to continue the plug it.
believe me not one is more anxious to try teh new functionality in teh plugin.
just a few more day to get the SDK to some stable point.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by blackbird_dream » Mon Jan 08, 2018 4:17 am
I'm patient and confident.
Best wishes for this new year.
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by Sweenie » Mon Jan 08, 2018 9:36 am
Hi.
I have now added raycast functionality(check demo 23).
Make sure to have Gizmos enabled to see the drawn raycast line.
This raycast should work like the one in Unity and also makes use of Unity's layer-system to filter out unwanted colliders.
- Code: Select all
world.Raycast (Vector3 origin, Vector3 direction, float distance, out NewtonRayHitInfo hitInfo, int layerMask = 0)
The layermask by default is zero which means the ray hits all colliders.
Currently i've added the layer property to the colliders, the layer defined on the gameobject isn't used but i'm thinking about adding that as well so you can exclude the whole gameobject(including all it's colliders)
In the demo I renamed Layer 9 to "No Newton Raycast" and made the capsule use that layer.
To exclude it during the raycast just create a layermask like this...
- Code: Select all
var excludeMask = (1 << 9); // Raycast against all layers except Layer 9
and simply pass it as the last parameter to the raycast function.
-
Sweenie
-
- Posts: 498
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by S. Darkwell » Fri Jan 12, 2018 12:58 am
Sweeny, thank you!
That'll also go a long way to allowing me to work on my project!
Is there any possibility of also exposing shape casts and overlap checks for boxes and spheres? I believe that if those were implemented, I would be able to begin testing Newton Dynamics for my project.
Thank you in advance, and be well!
- S.
-
S. Darkwell
-
- Posts: 8
- Joined: Thu Jul 13, 2017 5:50 pm
-
by blackbird_dream » Fri Jan 12, 2018 5:02 am
thk you very much for your new build.
I'll test it soon.
Meanwhile I was wondering about using the Physx Raycasting utilities in addition with your NewtonBody position getter. I did not test it and maybe it works either.
My first attempt with the PhysX Raycasting function was made with the gameobject position (i.e transform.position) and it was not satisfactory.
Hope I'm clear.
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by Sweenie » Fri Jan 12, 2018 7:56 am
Using the gameobject position for the raycast would be a bad idea as Julio mentioned because the transform of the gameobject is interpolated and most likely doesn't match the position of the rigid body.
Casting a ray based on the rigid body position should work better even whith the PhysX.Raycast i suppose, but mind though that PhysX.raycast won't detect any Newton Colliders so it would only be able to detect static physX colliders.
-
Sweenie
-
- Posts: 498
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by blackbird_dream » Fri Jan 12, 2018 11:04 am
Yep.
I anticipated this. In my case this is not a problem as the raycast is used for the tires to detect their current position with respect to the ground which is static.
I'll test both solutions. Anyway it's better (more relevant) using your solution.
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by blackbird_dream » Wed Feb 14, 2018 6:13 am
Hi Sweenie,
I'm back to your plugin. I tried to test demo_23.
As much as I remember I installed the plugin last month (plugin files are dated 1/8). Now I copied demo_23_Raycast.unity file in /Assets and Raycaster.cs in Assets/Scripts
When I load demo_23_Raycast in Unity the Raycaster object warns "Nothing selected" ("The associated scripts can not be loaded. Please fix any compile error and assign valid script")
Am I doing smthing wrong ?
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by Sweenie » Wed Feb 14, 2018 1:54 pm
Have you updated unity recently?
I had a similar issue a while ago and i think i solved it by copying the latest unityengine and unityeditor dlls to the bin folder of the plugin and rebuild the plugin.
Cant remember the exact path but they are somewhere under the mono folders of the unity install dir.
I guess what happens is that the plugin isn't loaded properly in the editor and therefor the gameobjects in the scene cant assign the components correctly.
Does the other scenes work?
-
Sweenie
-
- Posts: 498
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by blackbird_dream » Wed Feb 14, 2018 4:29 pm
yes the other scenes worked. I'll try to reinstall tomorrow
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by blackbird_dream » Fri Feb 16, 2018 4:56 am
I've reinstalled the newtonunity plugin and I get the same warning.
I did one more time and it works now.
I got 'speed tree materials need to be regenerated' when I launched Unity again.
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 4 guests