Newton Vehicle in Unity 3D

Share with us how are you using the powerrrr of the force

Moderator: Alain

Newton Vehicle in Unity 3D

Postby Sweenie » Fri Dec 18, 2015 7:14 am

I'm having so much fun with the vehicle in Newton so I thought it would be selfish not to share. :D
I also dusted off the old Viper Scout model from DexSoft which raises the vehicle simulation to another level.
Enjoy...

Keyboard(WASD/Arrows) or GamePad to Gas and steer.
Space for handbrake.

http://www.svenberra.net/NewtonVehicleTest.zip

Image

If you flip the car you'll need to quit the app and restart.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Newton Vehicle in Unity 3D

Postby pHySiQuE » Sun Dec 20, 2015 10:27 pm

Use Leadwerks and you will have Newton built-in already.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Newton Vehicle in Unity 3D

Postby Kaos » Tue Apr 19, 2016 10:51 am

I'm loving it. (some fast food comes to mind ;D)

I dont know what your plans are for this if you want a asset you can sell or just want a product that noone or at least not the majority of people got. But if you would be open to sharing this and arent sure if there are people who would be interested im sure many would be if they could get their hands on it.

Since Mr. Jerez is maybe working on this too, im not sure what the plan is here. But if everybody is making one for themself its just a bit unproductive i think.

So as a fellow unity enthusiast i would like to ask you if there is a chance you would share the source and or unity project or could give some advice or guide of how you accomplished this.


I would love to try to contribute some way if you would put this open source on github. If only by testing making demos and pointing at stuff or making and publishing tutorials for others if i can get my own head around it ;D but maybe i can even fix or add stuff even if im not a physics programming guru-

Since physx let my expectation a bit down when it comes to stable constraints and vehicle colliders im dying to get my hands on this to have some fun making things.

Besides from some pumbing behaviour while resting of the wheels which are only visible when the wheels are still on another phys body or better over multiple i couldnt make out anything troublesome. It looks like its even very stable when driving faster.

The vehicles in the demos have zero friction issues but there is already a thread about that issue ongoing i believe.
Kaos
 
Posts: 38
Joined: Mon Apr 18, 2016 11:24 pm

Re: Newton Vehicle in Unity 3D

Postby Julio Jerez » Tue Apr 19, 2016 11:02 am

Kaos wrote:It looks like its even very stable when driving faster.
The vehicles in the demos have zero friction issues but there is already a thread about that issue ongoing i believe.

in my last check in over the weekend there was friction issue bug it is fixed now.

As for driving a high speed, the is one last part of the vehicle that I have not completed yet,
The stability analysis, becaiscally these are the equations that control the lateral the vehicle steady state when cornering and a various some speed.
I have not completed it because I needed to complete some prerequisite first, but now is all ready.
I will do it this weekend.
Please download the SDK and check out the vehicle again.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Vehicle in Unity 3D

Postby Kaos » Tue Apr 19, 2016 11:56 am

my version was from the sunday evening european time so i downloaded the current one and its indeed diffrent and much better. The only unrealistic thing is that the car behaves to light its easy to flip and jumps very high but im sure thats manageable by code as you told me already.
Edit ; Options Exact solver on gives the frictionless feeling. Just for info.

All in all A wet dream from my point of view ;D

As for the unity plugin you were looking at or maybe working on any comment on what your own plan is for this?

Would you like to make an asset and sell or make a github open source project or what i could also perfectly understand you dont have the time yourself?

You know im coming from php and database development and made one little c++ app over 10 years ago and now some ue4 fiddling so i can read and understand it but i wont dar to get my hand really dirty right now. As for c# not really better since i only used it in unity so it would be a stoned plastered path to walk to try to get this started myself. Im better in working from a base up than starting a fresh one myself right now. And my guess is that will be the case for most unity devs.
Kaos
 
Posts: 38
Joined: Mon Apr 18, 2016 11:24 pm

Re: Newton Vehicle in Unity 3D

Postby Julio Jerez » Tue Apr 19, 2016 1:18 pm

:evil:
Kaos wrote:my version was from the sunday evening european time so i downloaded the current one and its indeed diffrent and much better. The only unrealistic thing is that the car behaves to light its easy to flip and jumps very high but im sure thats manageable by code as you told me already.
Edit ; Options Exact solver on gives the frictionless feeling. Just for info.


yes people will have different option on that. Here is the explanation for the high jump.
for that car I try to use realistic values from the data sheet of the 1996 Viper car.

It is support to be a high performance car with very short span stiff suspensions.
this block on the floor are much bugger that the side walk border, so when the car hit is if hit the suspension upper bumper. what you add to this that the vehicle is a rigid body.
when eth suspension hit the bumper the tire push the car up really hard, a real car will get totally destroyed because the chassis will to take that hit with out deforming.
It is actually the expected realistic simulation. I indeed worked hard to get that behaviors, is it in fact a feature.

to avoid that the suspension span should be longer, like an SUB or a monster truck.
I will add a monster truck demo soon. :shock:

But lie you said all those parameter are configurable
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Vehicle in Unity 3D

Postby Julio Jerez » Tue Apr 19, 2016 2:20 pm

Ok I added one of the improvement I'd mentioned: Aerodynamics downforce

now the vehicle feels heavies,
Please sync and try again, let me know if this si ok for you. :D
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Vehicle in Unity 3D

Postby Kaos » Tue Apr 19, 2016 3:48 pm

I wasent unhappy with what i saw so you didnt had to doo this. But since u did i downloaded and tried and now i had a real bug. The car started flying and rotating like crazy after a while. I couldnt repoduce this a second time in 5 minutes i tried so maybe a ramp in that level to flip the car slightly would help to pin this more easily down. I think i saw that in another youtube video where there whre similar issues. Actually in real life the bone would just brake by the force it took so maybe theres the problem somehow but there where no parts falling off so the car itself remains intact.

But i have to emphasise (i hope this is the right term) that you dont have to fix anything for me right now (or even ever for that matter ;D ) since i cant work with the engine right now anyway.
I started learning to develop plugins for unity and hit my first wall already because unity wont load my dll. Which should work fine and o wonder others had that problem too and it can have many reasons.
And now im feeling im going down that * endless rabbit hole again of browsing through a shitload off websites to find a solution that should have been given by the developer in this case unity in the first place. Or as in most cases browsing through boards because noone cares to update their wikis or manuals in this day and age. [rant over]

So i will come maybe back later these days when im actually come as far to use your library or maybe never if im getting too much resistance in making this work and losing interest therefore ...well see
Kaos
 
Posts: 38
Joined: Mon Apr 18, 2016 11:24 pm

Re: Newton Vehicle in Unity 3D

Postby Julio Jerez » Tue Apr 19, 2016 4:46 pm

Kaos wrote:I wasent unhappy with what i saw so you didnt had to doo this. But since u did i downloaded and tried and now i had a real bug. ...
I think i saw that in another youtube video where there whre similar issues.

I am not doing it for you or anybody else. I am doing it because I want to add feature to the engine.

I work on many feature in parallel, but there are not too many people testing anything at all, when some one ask for a functionality, I move to advance that particular feature.

As for the you tube videos bugs. yes you will see some Newton bugs in you tube.
most the time this is because when some one has a problem I ask them to make a YouTube video.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Vehicle in Unity 3D

Postby Sweenie » Tue Apr 19, 2016 5:34 pm

I have no intention of keeping this to myself or selling it as an asset. I'm currently fixing my implementation since the Newton vehicle has changed a bit since I posted the demo above. Give me some time to clean up the code and I will gladly share what I have so far. :)

Keep in mind though that this is still a work in progress and is not ready to be thrown into the fiery depths of the Unity community yet. :lol:

I don't want to release a crappy plugin, that will only reflect badly on Julio and the Newton engine.
But I would like to make a Unity demo that demonstrates how Newton kicks Physx in the nuts. :twisted:
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Newton Vehicle in Unity 3D

Postby Kaos » Tue Apr 19, 2016 6:14 pm

Those are great news and would be glad to give a helping hand.

Getting this right before getting it in the store or something is a good idea and a bug free stable version of the engine and the plugin has to be done before hand. And of course some Nice Demos.
The 3 Videos is saw of the engine in unity speak already for themselve as is my presence here the proof of that ;D

Questionable will maybe the performance in some direct contest because of the plugin and script usage vs direct implementation of unity.

I tested a bullet plugin in unity vs physx in not that easy to get right because of the solver iterations but from what i saw my guess is that bullet is a good third slower when stressed to the max vs physx.
The test itself is somethuing like putting 500 blocks together and let them fall to the ground. Funny enough the falling and staying stable together part is actually the more stressing part when all of them are tighly packed together and when all is falling apart its gets fluid again. It made sense seeing it afterwards because there are more collisions going on when they are all together but that tightly packed i had suspected that they would be computed as a whole instead of single units for the falling part because that could make alot of sense performance wise. BUt im a noob in those things so its interesting to see how things actually behave.

The part i was more interested then was the actual look / behaviour since i value that more over performance and interestengly physx made a nice impression when the solver iterationcount is cranked up to 100 (which is as high as unity alowws but nvida actuelly would support more) then a good third of all blocks would stack up on each other instead of just falling apart when touching ground. But then again the performance gets unplayable so this is in no way good for todays realtime gaming. Bullets collision looked nearly everytime the same so more or less iterations werent important for that test. the only diffrence were that the cubes werent that bouncy. But that s something i guess physx wants because there customers wants flashy bouncy behaviours for their games.

Well anyway that when i decided to give newton a try before fiddling aroud with bullet to get nothing better loooking instead only worse performance and time down the drain.

I bet newton would get his behaviour out of the box from what i saw in videos and the demo with the pyramid stacks which were real stable.


So as u can read im fire and flame and will test the * out of everything you give me ;D
And will try to get up to speed with the while native dlll thing anyway so maybe i can be of some help there too.

If you want to get out in public i suggest making a github project out of it and let some interested beta users like me join to help you get this going.
Kaos
 
Posts: 38
Joined: Mon Apr 18, 2016 11:24 pm

Re: Newton Vehicle in Unity 3D

Postby Kaos » Tue Apr 19, 2016 6:31 pm

One last question i do have for tonight before i can rest easy ;D

Is this working with real small and light cars like an RC car also?

Thats would probably be around 40 - 50 cm long and 3-5 kg and up to 100 km/h fast.
Or would that be an issue right now?
Kaos
 
Posts: 38
Joined: Mon Apr 18, 2016 11:24 pm

Re: Newton Vehicle in Unity 3D

Postby Julio Jerez » Tue Apr 19, 2016 6:40 pm

Kaos wrote:One last question i do have for tonight before i can rest easy ;D

Is this working with real small and light cars like an RC car also?

Thats would probably be around 40 - 50 cm long and 3-5 kg and up to 100 km/h fast.
Or would that be an issue right now?

It should work, with RC cars yes. there are some youtube video of a slot cars, which are a lot smaller, game that was made with newton 2.xx a while back, look it up

Kaos wrote:If you want to get out in public i suggest making a github project out of it and let some interested beta users like me join to help you get this going.

Sweenie I think that's a good idea, we can make a GitHub project and we all can contribute together.
One of the thing that I have been thinking about is to adopt a poplar engine to use as the sand box.
It find that is take more and more time to put together good demos.

For example last weekend I started to get ready for make the self balancing player controller.
I wasted the entire day just getting a skinned model. In eh end the result is that demos get more complex that the common person can not handle.

if I there was a couple of main stream game engines projects that I can use as sandbox, that make the process simpler.
In eh pass I tried with Ogre, OGL, and Irrlisth, but those are not really complete Game engines so in the end the plugin is not used because people do no know how to use by programming.

If you start the ball rolling by adding you project to GitHub then will all can contribute as a community project. I can make some contribution.
what I do no want is me because the sole contributors, because that has not work in the pass.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Vehicle in Unity 3D

Postby Kaos » Tue Apr 19, 2016 8:19 pm

I wanna point out that there are definetly some out there looking ;D

this guy made his own plugin https://www.youtube.com/watch?v=6O8_WX88QnI
i think he would a great addition to you guys and

When looking here https://sourceforge.net/projects/newton-dotnet/
you can see that an 3 year old wrapper still gets downloads because people seem to be interested in something like that.

I personally dont know how the feature sets of physx and newton are overlapping and if newton is lacking in an area which is important to a majority of people. Particles come to mind and im asking myself if its possible to use both physics engine in some ways together.
From a collision point of view thats clearly impossible but a simple particle system is also not that difficult to make a think. At least when its not doing 100k of particles ;D

And when it comes to popular engines you can only go for ue4 or unity and one could think and arque its better because you can get in the source and you can add your code native. But Since physx is pretty deep in that based too you would have a nightmarish time to get playing nicely with the basic components and stuff. Then theres the point that major AAA studios wont change the engine they will stick to physx that im pretty sure of. They want the name and the Gameworks stuff for the fanboys and because of all the other wrong reasons ;D

And the new indie and hobbiest userbase likes mostly to use the bloody blueprinting stuff ... a thats the other nightmare you basicly have to have a blueprint for every bloody class you write.
Many of them a grphic artists and those wont need this also because they dont do games that involve that much coding and Physicslogic.

I got crashes when i tried my own classes to use without going over an blueprint. So i dont blelieve you will find many adventures people there when it comes to physics. Even tho there are some that are unhappy with the state of the vehicle model like me. Compile times can also be a nightmare when you got an older cpu like me. And i doubt somehow that a simple plugin would do the job in unreal.

And Users like me would never touch ogre and most smaller studios choose Unity for the complete package and the wide range of platforms it can build to.

At least with unity you know its doable there is a halfway working bullet plugin which is mostly unkown for some reason since i didnt find it last year since then there was only a dead facebook page fo a plugin which then got some attention but the guy never followed through.
The bullet plugin i got is from here:
http://www.digitalopus.ca/site/bullet-p ... -unity-3d/

there is a facebook page which got 700 friends but i dont think thats the same guy and that plugin never saw the light of day ...https://www.facebook.com/unitybulletphy ... noscript=1

But it shows that people are indeed open for alternatives.
Just wanted to give some thoughts about this.
Good night ;D
Kaos
 
Posts: 38
Joined: Mon Apr 18, 2016 11:24 pm

Re: Newton Vehicle in Unity 3D

Postby Sweenie » Wed Apr 20, 2016 9:32 am

Currently I'm wrapping the Newton functions in a Unity plugin(which is statically linked).
One reason for that is because how Unity manages object creation and destruction and I needed to make sure that NewtonWorld was created first and destroyed last. Currently the plugin creates the world when it's loaded and destroys it when unloaded.
I think this can be solved though with a singleton trick in Unity and in that case it won't need to be a plugin anymore. Only the unityscripts would be required and instead I can call the newton DLL directly. That would make things easier to managed since I wouldn't need to maintain both the scripts and a plugin. I also guess this would make it easier for Julio to debug.

Another reason I'm using a plugin is because I'm using interops to call into Newton. However, the customjoints doesn't have a C interface so I wrapped the custom joints(including the vehicle) in the plugin dll. I guess I will still need to do that, but I won't need to wrap the standard Newton functions though, and that makes things easier.

Here is how the vehicle wrapper currently looks
Code: Select all
// Vehicle
NEWTONPLUGIN_API CustomVehicleController* fnNewtonCreateVehicle(NewtonCollision* chassiShape, const dMatrix& matrix, float mass, float steeringMaxAngle, float maxBrakeTorque);
NEWTONPLUGIN_API void fnNewtonVehicleSetCOM(CustomVehicleController* vehicle, dVector& com);
NEWTONPLUGIN_API CustomVehicleController::BodyPartTire* fnNewtonVehicleAddTire(CustomVehicleController* vehicle, dVector& pos, TireParameters* params);
NEWTONPLUGIN_API void fnNewtonVehicleSteeringAddTire(CustomVehicleController* vehicle, CustomVehicleController::BodyPartTire* tire);
NEWTONPLUGIN_API void fnNewtonVehicleBrakesAddTire(CustomVehicleController* vehicle, CustomVehicleController::BodyPartTire* tire);
NEWTONPLUGIN_API void fnNewtonVehicleHandBrakesAddTire(CustomVehicleController* vehicle, CustomVehicleController::BodyPartTire* tire);
NEWTONPLUGIN_API void fnNewtonVehicleSetEngineParams(CustomVehicleController* vehicle, EngineParameters* params, CustomVehicleController::BodyPartTire* leftTire, CustomVehicleController::BodyPartTire* rightTire);
NEWTONPLUGIN_API void fnNewtonVehicleFinalize(CustomVehicleController* vehicle);
NEWTONPLUGIN_API void fnNewtonDestroyVehicle(CustomVehicleController* vehicle);

NEWTONPLUGIN_API void fnNewtonVehicleSetThrottle(CustomVehicleController* vehicle, float throttle);
NEWTONPLUGIN_API void fnNewtonVehicleSetSteering(CustomVehicleController* vehicle, float steering);
NEWTONPLUGIN_API void fnNewtonVehicleSetBrakes(CustomVehicleController* vehicle, float brakes);
NEWTONPLUGIN_API void fnNewtonVehicleSetHandBrakes(CustomVehicleController* vehicle, float brakes);
NEWTONPLUGIN_API void fnNewtonVehicleSetGear(CustomVehicleController* vehicle, int gear);
NEWTONPLUGIN_API float fnNewtonVehicleGetSpeed(CustomVehicleController* vehicle);
NEWTONPLUGIN_API int fnNewtonVehicleGetGear(CustomVehicleController* vehicle);
NEWTONPLUGIN_API float fnNewtonVehicleGetRPM(CustomVehicleController* vehicle);
NEWTONPLUGIN_API NewtonBody* fnNewtonVehicleGetBody(CustomVehicleController* vehicle);
NEWTONPLUGIN_API NewtonBody* fnNewtonVehicleTireGetBody(CustomVehicleController::BodyPartTire* tire);
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Next

Return to User Gallery

Who is online

Users browsing this forum: No registered users and 20 guests

cron