#⚛️┃physics
1 messages · Page 33 of 1
in short: physx 3.4 and nested prefabs should't have gone into 2018.3 - since they are new and 2018.3 will eventually become LTS - which means more bugs to fix until LTS becomes stable, but - and probably mainly - people won't upgrade to 2018 LTS from 2017 LTS immediately, but 2017 will not be supported in short time; ( that's why they upgrade max. to 2018.2 - which is even worse from longevity standpoint :)
but I guess the phrasing was wrong - it should have been more like - no significant changes into .3 release (and LTS subsequently ), but some features should go into .3 release, of course )
I get it's easy to complain now though
nevertheless - we can ! :)
I'm not affected directly, but the state of physx in 2018.3 gave me a little pause, so I'll have to act accordingly
ah yes
that I fully agree on
I think major API breaking changes should be postponed to the next years first version if by any means possible
but then again, Unity cutting TECH stream support super early (when next TECH release is out) will eventually send people a message that they should stay on previous LTS as long as they can unless they are prepared to get surprises that might halt their projects and leave them without support
yea as they should - but what if they can't upgrade to next LTS as in this case ? 😃
it's easy to write 'significant' changes, but to actually define them is different thing entirely though
2018.3 changed a lot of things, prefabs, new physx, no legacy particles, new terrain system
also deprecated UNET
but they reversed that
and UNet is now valid till 2019.2 I think
I still feel that it would be more fair if people knew the upcoming major API changes early on before they jump into next years cycle
that way they can be prepared and not get surprised when things get broken in the last release of the year suddenly (by broken, I don't mean just instability but major change in workflows etc which can break a lot of existing codebase)
all these things considered, I now treat TECH streams as betas
and LTS as the real release
yea.. that's what I roughly had on mind with the first post - it's more complicated than that for sure, but "some kind of" a year closure with LTS would be definitely nice
I bumped into few bugs with tech releases in last cycle so I'll be definitely less eager to download new stuff too often (sad panda)
but they were not physics related so I'll stop ranting on physics channel now ]
@tardy spear re: PhysX 3.4: Is Unity setup with this flag: http://www.codercorner.com/blog/?p=1316 (PxConvexMeshGeometryFlag::eTIGHT_BOUNDS.)?
Oh I thought it was already a tight-fit as the option for inflating them changed
it's a new flag in 3.4, just curious as the blog post made it sound like it should be defaulted to on (unless you offer it as option)
and for the context if people don't know, that blog post is written by a guy who has worked for a decade on PhysX at Nvidia
I do have piles of convex objects (serious amounts actually, it's my main use-case)
so I would probably benefit from this.
I have a lot of destruction objects and bits
it's why I was thinking about moving some of it to ECS for the simpler (smaller) bits
that blogpost on codecorner - yes, PIerre is actually a co-founder of PhysX, alongside Adam Moravanszky
I guess from NovodeX ? that was entirely rewritten I think at some point if my memory isn't faulty
So for underwater physics...
Is setting the drag enough to make it realistic? Which value would be the closest to real life?
built-in drag in Unity = linear damping
so no, it's not enough for making it realistic 😃
https://en.wikipedia.org/wiki/Drag_equation should get you started
that'll not give you fluid dynamics but you can at least model believable drag force in different types of fluids (you can use that equation for air drag too)
that being said
if you don't really need realistic, don't do realistic 😃
ok
i'm trying to make an object with a rigidbody buoyant
how would I do so?
well actually I want to make it neither float nor sink...
you make the density of the rigidbody equal to the density of the fluid @clear fern
that doesn't work if you put things on it
use addforce to counter it's downforce instead
okay, is there like a formula or anything to do that? i've tried that but struggled to get an exact number
change forcemode to ignore mass
or divide by mass for force multiplied by fixed delta
this is very strange
the smaller cube is my fish (placeholder) and the large cube is a wall for testing pathfinding and stuff
I did something wrong and the two cubes are like magnets or something
You've got a pile of critical warnings and an error there.
As for null buoyancy, technically all you need to do is disable gravity. Is there a particular height you want it to tend to or something?
Hi all, I'm making a pool game, and it's the first time I have to deal with small scale objects. what's the usual practice when it comes to small objects physics?
I can see two approaches:
- Scale everything down to real life size => This gives me more realistic physics, but the lighting is really bad (shadows don't look good at all)
- Adjust physics settings to simulate smaller size objects => not too sure what exactly I have to change, was thinking to just multiply gravity by the scale factor (10x in my case)
what's the usual approach for this?
Make sure the near and far planes of your camera are suited to the scale and shadows will improve to match it
ooh right, didn't think about the near plane thanks
@hollow echo actually it's definitely not the camera, because adjusting the near/far planes didn's change anything, and also I don't see the shadows in scene view either
this is what it looks like scaled and unscaled
Hmm, well, usually if the shadow quality is low you can adjust them to fix it. But if there aren't any that's another issue entirely. Perhaps bias settings on your light
Actually that's it. Bias (0.0001 instead of 0.3) and near plane (0.4 = minimum) on the lights fixed it. However those are still pretty big objects (10cm balls) I guess if I was making a marbles game this fix wouldn't have done the job
@crisp panther physx actually hates small scale physics objects so scaling it up to 10x would probably only make it work better
Just change the gravity to 98 instead of 9.8 and put bigger impulses for the poolstick
If you do manual impulses that is
Actually my goal is to use this as a case study for ML 😃 so the agent will have to figure out the impulses themselves
thanks for the info though 😃 guess I'll re-scale everything back to 1:1 then
Use 1m = 1 unit. It will suffice from pea size to roughly the size of a city before float precision craps out.
(or 0.001 to 10k)
an extra nought (0.0001) is pushing it a bit much that would reduce precision quickly as you move away from 0,0,0
So it's not really physx more than physx just being set up for floats. Also, worth noting is that the convex hull routine does not work well at small scales like this either.
The manual probably hints that 1m = 1 unit is a good fit, in fact HDRP is set up for real world scales too, so it's a decent habit.
@tropic hamlet I once tried to make pinball game with realistic sizes and physx totally freaked out on the paddles if there was any angle to it, it was directly related to the world and object scale there but I spent ages trying to figure it out (as I thought originally it was just my own fault on the joint)
this was on another engine that uses 1cm=1 unit on physx though, but same physx nonetheless
that being said, in pool game you don't have joints/constraints, but you still do want as high fidelity for the collisions as possible
if it's like a bigger project, I'd just test different scales and see how they feel and play
you can even script this so it's easy to toggle between few options for testing purposes
Anyone got a problem with platformers type of games where going through a loop flips your controlls when you reach 90° thus making you fall ?
are you talking about a sonic-style loop-de-loop?
Yup 100%
Here is an example
Well i think its the problem
I have tried to tweek the ground check and the stick to surfaces rays but it doesn't seems to be the problem
looks like he is not rotating fast enough. Have you tried it with a ball.
uhh not really the character is not rolling im just adding forward velocity and the stick surface script rotates the rigidbody so it thinks i am always on flat
it just doesn't want to go through even going through clamping the character at the horizontal like at the end of the video
could that be the problem that you add forward velocity instead of adding a force
what do you mean ?
he is always falling down at 90 degrees
rb.AddForce()
at 90 degrees gravity let him falling down to the ground
you mean that the gravity is stronger than the velocity applied ?
I think there is no force pushing him to the ground and then he is falling down like in real live if no force is goind to the ground
i dont get it
i'll try rb.AddForce
What the hell is that brainfuck 😄
i doesn't work
😄
it just made me mega slippery for some reason
but by some witchcraft it kicks him off the slope at the same point
and its not the slope itself i got an other that go on the side and it pulls me back...
WhY
looks like you're only accelerating forward, not into the direction your character is facing
you mean in the world forward ?
looks like the same problem
i wouldn't be able to turn if it was world forward
from what I see in the video I would say there is no centrifugal force
🤔
How about posting the code that actually sets the velocity ?
Centrifugal force is a force that only appears in rotating coordinate systems
rb.velocity = (transform.TransformDirection((new Vector3(rb.velocity.x, rb.velocity.y, newDelay * 40))) * Time.fixedDeltaTime);
i dont think that this setup even produce centrifugal force
and centrifugal force is the force that hold you in the slope if you are running. It always points to the ground
yeah but i would be able to pass it
why am i being pulled away
also is it the right way to leave the x and y values untouched in the code ?
i still get floaty when im near the ground while moving
You're basically transforming your direction from a local to a world direction, not too sure why you're doing that
you probably just want it to be transform.forward, so the velocity always points into the forward direction relative to your character
I don't know if your character & rigidbody are aligned
yup it is the model is a child
rb.rotation = Quaternion.Lerp(rb.rotation, Quaternion.Euler(transform.eulerAngles.x, targetRotation, transform.eulerAngles.z), 0.5f);
thats the rotation part
If they're aligned, just replace all that stuff with something like
rigidbody.velocity = transform.forward * input * someSpeedConstant;
@Dirk and @bleak folio seemed to have you covered, but if you want to deep dive into the underlying logic of how the old sonic tile collisions worked, you can take a gander here:
@blissful shore thanks
@bleak folio i tried your thing surprisingly the player moves the same but the problem persists
Well, either the rotation is off (the code you posted above just lerps between some rotations) or there's a different problem. Kinda hard to tell with the information you have provided
your best bet is to visualize the direction you're moving into, e.g. by using Debug.DrawRay or something similar
im trying that to see where the controller points
uhh you mean the player or the controller input ?
I’d start off by drawing the velocity, that’s basically just a directional vector multiplied with some constant
So you can do something like
Debug.DrawRay(transform.position, velocity.normalized * rayLength, someColor)
something like that ? Debug.DrawRay(transform.position + Vector3.up * 3, transform.forward * rb.velocity.magnitude, Color.white);
oh ok
Lol it worked at some point i got scared and let out of the controller
is it working?
nope 😄
😦
The direction seems to be right, kinda hard to tell at that speed. Looks like you need to go faster to make it through
yes, give him more speed 😄
really ? ok i'll crank that blue blur 😄
Might also be a problem with your input. Thats something that often confuses me in games where theres such things as loopings 😄
yeah must the inputs that flip or something :/
i tried with more speed it goes further in the loop but its the same result
well that is if i can get to the loop with a speed of 200 😂
is the gizmo in the video from the character?
@inner cloud are you having issues with running the loop?
I assume holding forward should keep him going through the loops?
yep
if that is the gizmo from the character it doesnt rotate
I did something to combat this with 2d recently, might still apply to 3d. Try checking the angle of the forward you're running on and - forward against your velocity
im in global
Or input perhaps in your case
Whichever is smaller is what you should apply as the velocity direction for forward
Youre basically checking whichever direction the object is facing has the least resistance to your input
Then using that as your velocity direction
You could also apply force towards the hit normal and character forward
Might be an easier solution
Hit point, sorry
Hit point being what's below ur character
So -transform.up
Not at my computer and working this out from 2d to 3d...have you tried applying force of transform forward and down?
Maybe less force on the down
hold on i am trying to understand 😄
yes you could fake a force down to hold him on track 😄
a constant one ?
constant or depending on his speed
Try what I just suggested first.
Add force equal to transform forward and - transform. Up
I feel like that should work
something like rb.AddForce( transform.forward - transform.up) ??
maybe something like
Vector3 force = (transform.forward + (-transform.up * 0.5f)).normalized;
addforce(force * speed)```
note Im only adding half of the downforce so help prevent him from possibly sticking to the ground, making it harder to climb loops
how that behaves would depending on your drag and speed though
i'll try
you know what would be better
something like this
Vector3 downForce;
if (grounded)
groundForce = -transform.up * 0.5f;
else
groundForce = Vector3.zero;
Vector3 force = (transform.forward + groundForce).normalized;
addforce(force * speed);```
that way you arent adding upside down force if hes not on the ground
stopping him from running upside down in the air lol
or you would have to manually flip h im and keep adding the ground force
slow down his speed and reduce the gravity modifier on him. maybe youre jsut steering him into the walls.
are you using a joypad?
or mouse for direction at least
does he only turn the direction youre moving the joypad?
or that of velocity
because you cant really turn him based off velocity
for me it looks like the force is not going in the direction he is facing
try slowing him down and do traces the direction youre adding velocity to
I feel like my suggestion would have worked. why is he flipping directions in air
me thinks its an input thing
yeah we came down to this conclusions earlier
i'll still try what you just said but it really feels like a input thing
it looks like you roate him with an animation but you don't rotate his parent where you adding the force
no root animation + the model is a child of the actual "player" its just cosmetic
and it works every where even on almost 90° surfaces because i am only adding forward velocity and the rotation is from the hit.normal
tbh his movement seems to be exactly what Id expect with his facing
so im thinking steering
what do you mean ?
in the video he turns right, and cruises in the right direction into the wall then falls off
thus movement is probably working as intended
makes me believe the steering is wrong
shrug
I can take a look later tonight if you still need. I'm trying to get some work done atm.
yeah np i need to go too i got work tomorrow
thx guys
@naive summit @stuck bay @bleak folio
np
aye see ya
Does Rigidbidy2D.position just pull from transform.position? (And same with rotation?) They wouldn't ever be different, would they?
(The docs don't mention anything other than The position of the rigidbody.)
@lilac lark You're correct. But if you need to move the transform it's more efficient to set position by modifying rigidbody.position
Cool, thanks.
@lilac lark If you use interpolation/extrapolation on the RB then the Transform is updated per-frame and won't be the same as the RB position/rotation. Without that, it's always in sync. Interpolation means "Update the transform per-frame from the previous RB position/rotation to the current RB position/rotation". Extrapolation means "Update the transform per-frame from the current RB position/rotation to a future position/rotation based upon the current RB linear/angular velocities".
If you're manually simulating per-frame then you don't need to use interpolation at all and the transform will always be in-sync with the RB position/rotation.
Rigidbdody2D.position/rotation is stored on the RB itself and is the authoritative position/rotation. It gets written to the Transform. during write-back (post simulation update). If you change the Transform directly (avoid this if possible) then we have to update (amongst other things) the RB position/rotation.
Very good to know, thanks! 😃
Np at all.
Hi @ocean horizon nice explanation! Could I ask you If Do you know , having a large number of rb, with animations , in terms of performance, is better to not interpolate at all?
interpolate does generate some small overhead, it will animate the object every frame to show smooth movement
but it's not a radical performance hit
if your running in physics performance problems
you could try tunring down your fixed update rate
and keeping interpolation to keep it looking smooth
by defeault unity is having a physics update rate of 50 times per second which is a bit weird to be honest
cause most games target 30/60 fps
so you rather just set your physics to that..
for instance you could put your physics update to 30 times per second
and even run your game at 60
Wont having 60 hz physics update with 60 hz framerate cause double physics update on some render updates, and on some zero? That would probably cause more visual artefacts than having it at 50.
it wouldn't matter, as unity samples physics at a point after FixedUpdate, which runs faster than framerate anyway.
basically framerate and physics are completely independent of each other.
@autumn jetty well, 60Hz physics would appear smoother than 50Hz physics, and yes, sometimes it means you get zero updates for one frame unless you use interpolation or extrapolation unless you substep your physics simulations manually
what happens by default on Unity is "Free the physics" part on this article: https://gafferongames.com/post/fix_your_timestep/ (and last part if you do interpolation)
and just to avoid confusion: there's no separate physics thread that runs the simulate commands totally isolated from main thread, it's literally running just accumulated physics steps in series from the main thread, just like that execution order graph shows
yeah if you ran physics at 50hz, the same thing would happen at 50fps
so there's no magic number that is going to always guarantee a physics update every frame
(and nobody can guarantee their game always runs at 60fps on every PC heh)
well, the physics steps will overlap at some point always, regardless if you run them at lower or higher Hz
What I meant was in regard of not using interpolation
well, running physics at 50Hz will not help at all on the stuttering, it's actually worse
Interpolation sorts it fine, been doing fixed timestep ever since mark sibly introduced us to the concept in Blitz3D, it's realy solid and scales, just need everything outside of it to be interpolated. That's kind of how I'd like my ECS worlds set up too.
a world for doing logic at a fixed timestep would mean one could even just remove delta time multiplications from everything and simulate at 60, interpolate to refresh
if you do ECS, I'd try doing the interpolation on jobs, might get some perf boosts on that
(instead of using the built-in lerp)
yeah that was the plan
but thing is trying to do ecs at a lower granularity is also a bit shit at the moment
that is, if you can even measure the interpolation cost (doing extra optimizations for sake of doing them isn't really great plan) 😄
for example doing ECS updates at 1/30
but I've seen some overhead from Unity's interpolation in past
(on some low end computers)
could be some user error though, interpolation shouldn't be that expensive
there's also a nice idea I just had...
what if the interpolation was moved to the gpu?
should be feasible actually
vertex shaders?
I'm mainly worried about the rotation as you'd probably need to recompute all the normals then too?
I don't think the steps will be large enough to see those errors
still, interpolating on cpu isn't a big deal either
and if it's all deterministic it might be smoother
physics + dots + networking? very fun man
does big lebowski far out look
still hoping they'll release that HPC# physics soon :p
how far along is that anyway?
only Unity employees know
Yeah look at them sniggering in the background all secretive like.
but that grin on Joachims face at last Unite when he talked about this .... 😄
I really freaking loves Joachim's expression when he revealed megacity on a mobile too. It was as if it was justification for how kickass DOTS was, and a dream come true.
proud father of a digital mutant that would one day grow up to terrify the world, artist and programmer alike, spreading through visual sctipting, and even taking over sound itself...! there would be no escape from performance by default.
Joachim Ante opens the ECS track by presenting what he and his team have been working on for the last 6 months. More info: https://on.unity.com/2Q5KxR1 Joach...
heh, yeah that expression was loaded with many emotions hehe
If have 3 different objects of type A, B, C
how can I do it s.t.:
- A and B have trigger only collision
- A and C, B and C have resolved collisions
- A and A, B and B have resolved collisions ?
@median frost : Basically A&B don't collide, but you need to detect the case where they would. I'd do this by getting creative with Layers and child objects. You give A&B two layers and use the collision matrix to prevent them from colliding. Then, you give each A a child object in B's Layer with a trigger collider... Alternatively, you could have a non-child object complete with its own massless Rigidbody that's simply connected to A by a FixedJoint, and place the B-trigger on that.
@sly violet thanks, that sounds very good
how do I make a 2d rigidbody perfectly bounce of a surface?
I have set the surface physics material bounciness to 1 and friction to 0
but it still looses velocity every time it hits the surface
@median frost
I guess that is Is the rigidbody the one who slows down, not the material
The drag value is the one you want to change
Is bounciness 1 on both colliders' physics materials?
Just in case anyone's interested - the PhysX 4.0 builds are going to start appearing in this thread: https://forum.unity.com/threads/physx-4-0-in-unity.634960/
Hey @tardy spear what kind of extras does 4.0 bring over 3,3 for unity?
FYI we have 3.4 in Unity 2018.3
yes sorry 3.4
The engine has been upgraded to provide industrial grade simulation quality at game simulation performance. In addition, the PhysX SDK has gone open source! It is available under the simple 3-Clause BSD license. With access to the source code, developers can debug, customize ...
I'll be sharing more details on that thread I mentioned above, as the PhysX 4.0 features get exposed
btw, is this ever going to be made? https://feedback.unity3d.com/suggestions/separate-physics-and-render-laye
Having physics and rendering use the same layers is counter-intuitive, leading to sometimes complex setups for simple cases. ie. Wit...
We are having a giant problem with the layer limit in our game
Some gifs of what's coming soon
Articulations!
this is articulation too
the red spheres are 200kg heavy, the blue ones are 1kg light
(see -- no springy-stretchy stuff at all)
I don't yet have articulated drives, but they're coming. For now, here is a stickman dude for inspiration https://gyazo.com/e1d81f5b67938e311c24d693e0888fc6
Layers - I think that will get solved but won't be able to share when exactly
Alright, another question, any idea how to make two rigidbodies collide with eachother whilst not pushing eachother, and they have to have the same mass,
because in this example its two players that for game play reasons shouldent push eachother
we don;t use the character controller because it is way too cpu intensive to have even 100 players in the game
their just rigidbodies that get forces applied.
yeah, that would have been solved if we had contact modification exposed
no way around hacks today, perhaps
My current hack is to capsule cast non alloc into the direction movement and if hit another player dont move
but it's not an ideal solution cause it creates unsmooth movement if lets say two characters are folowing eachother
because if they get to close one freezes caus we hard set velocity to 0
an option to smooth out the movement dident work either
cause they start pushing eachother again
it's a mess really
It's actually a very very common use case and i think many guys are running into this problem
all you basically want is to bump into an object but not push it at all
Any chance on getting contact modifications exposed?
@tardy spear really cool that articulations are coming!
about that physx 4.0, can you tell what feats will be on that special build?
would love to try it anyway, just curious if batched queries are included 😃
batched what?
there will be just a raw mac build of 2018.3 just with PhysX 4.0
in updates - articulations, bugfixes, temporal gauss-siedel option, new broadphase option (an automatic multi-box pruning stuff)
I mean stuff like raycastcommand etc (what I try to ask, is all old functionality there?)
also, will there be windows builds? 😄
I had to exclude Cloth for the moment. Everything else should be reasonably there
ah, that's cool
I'll start with Mac and expand to other platforms in the coming weeks
also looking forward to especially to testing the new solver when you get that added as option 😃
it's the highlight of 4.0 after all
I do have an object X which is stacked, and thus has a Rigidbody and a BoxCollider. My input (raycasts) needs to detect in a smaller hitbox than the hitbox the Rigidbody is using. How can I solve this? I tried using a child with a smaller boxcollider, and setting 'Ignore Raycast'layers (and masks) on the parent, but that does not work either.
(2D)
you have separate (kinematic) rigidbody for the inner collision?
I dunno how this works on 2D side, you'd need that on 3D for all dynamic collision objects
@fiery elbow
oh that makes sense
ill try that, thanks
solved it! I accessed the wrong collider + didnt setup the boxcollider the right way. still thanks 😃
@pearl warren : Maybe instead of a hard stop in all situations, use Vector3.Project (with the velocity of the character you bumped as "vector" and your own velocity as onNormal) to get a new velocity in the same direction, clamping the result somewhere between the current velocity and stationary? That way, if you run into someone going more-or-less the same direction, it'll only slightly lower your velocity.
@tardy spear you told me YEARS ago you had this stuff in mind :D do you really plan your to-do list so far in the future ?
you mean the articulations?
I am soooooo excited for articulations because currently nothing truely feels right when doing any form of joint as we have to reduce mass as we go along the chain
yeah anthony mentioned wanting to do it about 4 years ago ...
afaik they bring their own limitations but actual joints should be super stable
Yeah I have an idea how they work, done a few of my own but I prefer this done by someone with far better maths than I
I almost started implementing these for UE4 at one point but didn't want to go through their UI hell
I used them for anim bones, grapple, blendable ragdoll etc
I still do, just now I can remove my code it seems
you mean like custom physics implementation?
Is he using temporal gauss-siedel to solve the rb positions from articulation?
there's not been any way to get access to physx articulations before in Unity
yeah it's been a pain
at least I could move my character controller from using overlap+compute penetration hack to just using oncollisionstay, something that was impossible before with allocations. It's still less perf than the compute pen approach, but the code is so much cleaner and extensible I have chosen to just go with that
I dunno if that is even used in articulations tbh
yeah well i'm always 100% excited for physics, it's my main gig
but I'd love to see the new solver in regular joints
yeah, nice to get sneak peeks for sure 😃
i wantings
my physics christmas list goes like this:
- perf
- unlimited strength chains and grapples!
- convex hull improvements
- some more perf and faster on collision stay style stuff (for char controllers or other things that need every frame contact info)
- anthony back massage in exotic location of his choice
mine is
- HPC# Physics
- contact modifications for PhysX
- exposed physics stages for physics
- direct convex sweeping in jobs
- split convex baking in editor
1 and 2+3 can kinda make each others bit obsolete in my own use cases, depending on their implementation. Getting full source access over everything is going to make easier to change the core functionality instead of relying on Unity exposing needed bits (and keeping them functional from release to another)
- is going to be a while. Subscenes are with us now so that's a vital step
for sure
I dunno if HPC# can be compatible with regular physics in unity, do you know?
that is, will unity make them work with each other?
box hits hpc box
I really hope it's a things built from scratch
Anthony would know, we just need to trick him telling us that 🤔
I think it has to be for DOTS but it does not exclude the two systems from passing info back and forth
well, the exposed physics stages thing would allow us to utilize physx betting in jobs and ECS
as we'd get the raw data then and could set it on jobs too
likely we will have to do it ourselves but the problem here is access to the proper data at the proper stage
and physx isn't exposed like that yet
like needing contact info before it reaches everything else
OH
u said before me :(
it seems you're actually after the same things I am!
well, I need certain things from physx which Unity doesn't expose right now
I'm currently ignoring that and focusing on other things
but I need to tackle this one point or another
my earlier setup relied on Bullet physics
that's always an option for me even still if things don't happen fast enough on Unity's side
(which is very likely to happen)
my physics solver needs aren't that difficult though, so will wait for GDC before I make any bigger changes to my physics code (besides my ECS experiments)
WHAT IS BEST IN LIFE, CONAN?
To crush your enemies with #HPC physics, see them HDRP rendered before you, and to hear the lamentation inferior compilers!
I can make custom solvers for my rigidbody needs just fine, but I'd rather not implement the broadphase on ECS myself as there's a lot of fancy voodoo magic people can make there when they know ECS internals better
Currently I've used ECS to create physical objects with limited use because I lack the experience to do a proper implementation in ECS yet. For example nothing rotated
and things like joints were pretty much impossible as I was still stuck in the ordered mindset required to solve
Does anyone have a good resource on dampened follow cameras getting the jitters when targeting physics objects? I have found countless threads online over the years that all seem to end in "Unity's fixedupdate system will never look smooth with a dampened follow cam".
@tropic hamlet I'm working on a IK solution with ECS and the order issue was a nightmare. In the end I gave up and stored a few things on the system
So far, I have used rigidbody interpolation, smoothdamp function, and written my own timestep interpolation, all of which produce noticeable interference patterns between the two timesteps. My custom interpolation is the smoothest so far, but it is noticeable none the less.
The good thing about that was that it gave me a performance bump since I was only using 1 rig = 1 entity in the end
I like to think that sometimes, not trying to make EVERYTHING an entity is actually a good practice
@somber bison for cam follow rb, rb must be interpolated. If it's cinemachine then I have no idea what they're doing.
also cam must be done in lateupdate, or rather that's where I do it and I follow my rb controller all the time and it's silky
The targetted rb is of course interpolated, but does not produce smooth movement for the camera's update
put cam in late
also no affect on the issue
are you following transform.position or rigidbody.position? only transform will get the interpolated data
it is caused by an interference pattern between fixed and update (or late update)
once each time cycle (a second or so depending on fixed timestep), it will either not run a physics sim, or run two
in that frame, you get a very jarring stutter
that's fine - that's what interpolation will deal with...
it does not
this behavior is reproducable with a single bouncing ball and a camera set to interpolated tracking
is it a cinemachine camera or your own?
my own
and the camera is in late update for sure?
yes
what's the camera code for the simple test?
question, the bouncing ball is run via physics sim and not your own code, right?
that is, it's just left alone and is bouncing
transform.position=Vector3.lerp(transform.position, target.position-transform.forward*distance, dampfactor);
you get a stutter hitch once every half second aproximately, when running at default physics timestep
at 60fps
meaning built? not in editor? I can see the behavior in both build and editor. vsync is on
(0 sync per frame)
there are dozens of threads with exactly this issue
eventually someone always says "Unity just isnt built to smoothly show physics in the update timing"
yeah but please - 99% of people posting aren't doing much right to be honest
so i have to be clear
I am almost 100% certain it is not a vsync issue. physics is updated 50 times per second at 0.02 fixed timestep
graphics are updated 60 times per second
yeah sure but there are actual problems with vsync right now
oof, I did not know that
yep unity calcs it like shit.
Well that is good to know. Is it good practice to run unsynced?
they can eliminate that micro stutter which is evident anyway, I'm guessing it just amplifies the physx problem you're having
i think a game should run synched to be honest
Yea, I can minimize the issue pretty substantially by running fixed timestep at 0.15
but I run unsynched and don't get the camera issues, and my fixed timestep is 1/60
But the issue isnt gone, and I have to believe there is some best practice, as interpolated camera on a physics object must be very common
i have the same problem actually
the game became livable with motionblur to hide this
using unity postprocessingstack
it's very common, I've done it for 10 years in unity. thing is the ball will always not have arrived at it's destination for even a double frame to cause a problem, which is why it's probably not a fixed timestep problem.
but its shit to have this jerky movement
that is, interpolation is still covering that gap in time
Yea.. It is frustrating for sure. I appreciate you sharing your experience @tropic hamlet
What is your fixed timestep @pearl warren ?
Bumping mine just a bit so it is above 60 helps dramatically (though not perfectly)
for a pause or hitch you need interpolation to have the same source and destination parameters during the time 2 physics updates occur, and this basically never happens in reality, with the worse case having the camera perhaps change velocity ever so slightly in 1 frame. but this would be gentle and not a stutter
I feel like the correct answer is to keep a log of positions over the last quarter second of fixed updates and just.. do some sort of dramatic dampening yourself
my fixed is on 30
I just wish that is what the interpolation option did
that should be enough 😦
all interpolation does is a classic lerp from old pos to current pos, there's no kung fu here
how big are your objects? assuming 1 meter
yea, so a lerp that takes more frames into account could be a good bet
yea about 1 meter. character controller 😛
Hmm. I don't seem to have these problems. I'm using a Rigidbody not a CharacterController, and LTS.
there's 0 cam problems here, i work on cameras a heck of a lot so this issue, I think it might be deeper than just interpolation
If your camera is parented to your rigidbody, you dont really get the issue
only if you want a dampened follow camera
no, mine's properly separate and the camera code is in late update
my camera is not damped at all
interesting. the dampening might be making the hitches more visible
if your cam is damped it needs to be temporal
I tend to use lerp with a timestep in the last parameter to produce a % per frame ease.. its a bit of an abuse of the lerp function but should be mathematically sound
lerp shoulden't be used like that though
I'm ok with that but you need to multiply by delta if you're "abusing" lerp - which isn't really abuse imho, just another use
but doing that, you defiantely need it in late update and need to multi by time.delta
it's not called a lerp any more when used like that but you'd use the same math so it's just semantics mixed with different developer experience levels that causes people to shout about it
@somber bison you sure the stutter is actually from physics movement and not some GC spike?
current HDRP for example generates a ton of garbage
Good question. I can profile for it
The behavior though is very predictable. and fluctuates with fixed timestep
2019.1 has incremental GC on builds as option, it will help a bit if that's issue
but what comes to the vsync thing hippo mentioned, it's an issue that runs quite deep
good to know, ill look into the option, thank you
what Unity does there actually is technically correct, they measure the deltatime between the two frames
but since we render things into buffer, it's not all that straight forward
Yea thanks @tropic hamlet, I am using delta in the progress parameter as you described.
the issue is that the moment we get some variance in update times, it doesn't mean the renderer will have it when it displays those frames
which causes the difference and jitter if you still compensate for it
Interesting. this seems to also point to smoothing over a larger set of frames being a good bandaid solution for the issue.
it's not a trivial thing to solve and it's been discussed here https://forum.unity.com/threads/time-deltatime-not-constant-vsync-camerafollow-and-jitter.430339/
My camera does not need to be snappy, I can spare a quarter second to aggregate frames
they have a test script there but I've seen this on other profiling tools as well
Thanks for the link, putting it on my reading list
when you run Unity with vsync you get this kind of alterations on the frametimes: https://forum.unity.com/attachments/upload_2019-1-15_18-53-35-png.359692/
when you'd expect that to be straight line
this was linked on that thread: https://medium.com/@alen.ladavac/the-elusive-frame-timing-168f899aec92
yikes.. that looks startlingly like the interference pattern I thought I was seeing..
it explains the underlying issue
smooth delta won't fix it either, it needs to be measured properly
But I think this is the real problem, not fixed timestep, although when fixed fires might be worth tweaking
(player update)
"Six consecutive frames from the comparison video, with precise timing. Top is correct, bottom is heartbeat stutter."
https://cdn-images-1.medium.com/max/2600/1*50pqw1PofTAJdqmZR2JBgA.png
"Ah they said they closed the 977641 bug ticket because they consider it a feature request, not a bug."
so the stuttering, unity is happy to leave it as something unimportant to them.
lame
so, roll out your own solution if this happens with your project
That hurts
it is lame actually since it's totally fixable their end
but... there's like ton of different reasons why Unity games can stutter
that's only one of them
and it is a bug not a feature. in what world does correct frame timing mean "feature" ?
their current timing is technically correct
yeah but this is the one that nobody can fix without source.
that's the issue
I've clocked the deltatime myself manually and it's in like with Time.deltaTime
its not technically correct unless in a void. last i checked unity isnt a void
so it's broken for its common use cases
what they'd need is some perceivedDeltaTime or renderingDeltaTime etc
What is Time.smoothDeltaTime?
funnily enough, I don't see this in UE4 at all
just an average I think
and they measure the deltatime there EXACTLY like Unity does right now
Documentation is hilariously tautological
there's just some inconsistency on the rendering side in Unity that causes this I think
I love those doc pages "Time.smoothDeltaTime: a smoothed delta time"
smoothed just averages few frames if I remember right
@somber bison that's basically taking the last x deltatime values and average them
funny how UE4 doesn't have the problem
Would this be a poor man's "perceived delta time"?
no, it's a red herring. it's useful if your stuff is already smooth but you want to handle bumps in the road without much care. it doesnt fix this problem..
take your game
put camera down in the scene
dont have any scripts on it
put in front of it an object
some mesh you have
doesnet matter what
add a script to this with this in update:
we should mo e this chat into #💻┃unity-talk
transform.rotation = transform.rotation * quaternation.Euler(0,90f*Time.DelaTime,0);
then let it run
voila stutter as HELL
Good point, the physics portion of this conversation was based on my first guess at the issue
That is a really interesting test case @pearl warren .. :/
look at result here
Just like his companion in the previous video, the enlisted in this video decided to ditch his knapsack and wear a blanket roll instead. This particular sold...
this is exactly that in our game
Time.DeltaTime is weird
if you change example script to this:
transform.rotation = transform.rotation * quaternation.Euler(0,90f*0.01666666666f,0);
its much smoother
yikes
but not frame rate independant ofc.
that makes sense
it makes no sence to me
why it's so jerky
fps was 60
there was no GC spike
rigidbody interpolation is based on this Time.DeltaTime
so it also stutters
so when you use a camera in late update
it also stutters
yay
This is really good info. I know it is frustrating, but I really appreciate the learning experience. I can bandaid this crap better now 😛
Thanks ya'll
The question is does anybody know a good solution
You could check the deltaTime and if it's around the same ballpark consistently, just use some avg (and/or your own set values for common figures) that stop the fluctuation while it's around that ballpark. If you actually get some real spikes, you just drop out of the fake setup and use whatever Unity is telling you then
it's bit hacky for sure
this would only fix the cases where people run with vsync enabled of course
if you have something like g-sync/freesync/adaptive sync, there's not much you can do (but I dunno if this issue is as noticeable on those displays even)
Also worth noting that afaik, the exact refresh rate on most monitor panels isn't 60.0 Hz but something near it and the exact refresh rate can probably vary between computers
so, you'd still need to occasionally correct the drift from real measured time to what you told your game it was at
or adjust the preset "fake" refresh speed to compensate on that
everything here of course only applies if the jittering truly comes from Unity's rendering and not from your GC spikes, bad input data, broken interpolation code etc
I mentioned input as previously the mouse input data could be horrible in Unity's input, had huge jittering issues with mouse look on mouse which didn't happen at all when doing the same movement on gamepad
input issue isn't trivial as gamers can have really different mouse hw and sensors
you shouldn't be making physics updates in update. It should be in FixedUpdate.
that's why you're seeing stuttering.
and moving something is a physics update 😛
though this guy argues camera movements should be in LateUpdate(), and he may have a point:
That wasnt really for making physics updates in fixedupdate bit rather updating camera that follows rigidbody object
well camera updates should be in fixedupdate or according to this guy, lateupdate
I just ran into this issue with someone's asset 2 weeks ago
they had terrible camera stuttering and said it was due to a bug in 2018.3
but I found the same issues in 2018.2 and came to find it was just their code. They had all the camera stuff in update. I moved it to fixedUpdate, and smooth as silk
(but now I may try lateupdate and see if it's better/worse)
I think I learned this from Unity's character controller, they make a point of explaining how camera stuff should be set up. (Or It may have been one of Unity's tutorials I did years ago. but in my brain it's become an indelible fact that camera goes in LateUpdate() )
I wonder if that's why Cinemachine camera stuff is so stuttery
would be ironic if they don't follow their own advice with that.
but I assume it's because it's so process heavy
they tack a ton of stuff onto that camera movement.
You cant have fully smooth camera movement if you only use fixedupdate for it
Also using fixedupdate doesnt make any sense for most camera scripts as you end up calculating extra stuff that is never used if that main loop has more than one physics update
well that's probably why he suggests lateupdate
and really you make the point for that
so i'll definitely have to try it
late update IS update. it only ensures that it happens after your other monobehaviors call update
it is not its own separate update
fixed update and update happen on an entirely separate clock
update and late update happen in a predictable order every frame
Well.. Technically fixed updates run on same main loop iteration too :p
@somber bison not true
yes, but not predictably per frame
the key thing being it happens after animation updates
which at least for some things, probably is best
notice there are no conditionals in that flow between update and fixed update
it's not a 100% accurate representation
physics can run, then outright run again without ever running a lateupdate
Not sure what you mean by that
it's just a guide for order of execution
yes fixedupdate can execute multiple times in the space of one update
I never disputed that
It does get more complicated when monobehavior execution orders and stuff get considered
I'd disagree on that too
why not use player-update ? you can contol the order of all of this yourself with the player API.
then you will realise you aren't fixing it still
Well.. That makes things more complicated
man this page renders so badly on my browser
And yeah, it is not solution here
let me try another
My only clarification was that when the question is "How do I solve for an unknown amount of fixed updates causing jitter in motion" is very often answered with the suggestion "put it in lateupdate", which does not help the situation.
- you can control when physics update, or even trigger it manually
- you can control the exact loop order and when too
you have zero limitations in that respect.
the problem is deeper than physics
coroutines is another thing.
I think that guy's code used a lot of corutines
i feel like i tried lateupdate though and it didnt' work either.
I don't have a single co-routine, they suck bad for perf and have zero purpose other than waiting for a web query
but i'll have to try again to be sure
I dislike coroutines too, people overuse them
i the end getting a stutter free camera is the goal, not what is technically right 😛
honestly it gets on my tits that even Unity's own docs championed co-routines for so long when time slicing it manually is more efficient
I like coroutines for "asynchronous" batch behavior, like instantiating a set of things for future use
but it's not...
I've seen people using them to implement "update" again
thats why they're so bad. people think co-routines run off the main thread or something. they just get called in playerupdate like any other at set times
I know it isnt asynchronous, so I put it in quotes
it just spreads the call across frames
its just time sliced and creates garbage by default, setting you up for pauses.
coroutines aren't async, so why would they use it to make 'update' lol
I guess some people just feel they do good when it is different from stock
i truly try to stay away from corountines
why not just set a var by current time, then each frame compare var subtracted by current time and that will tell you when to call a function. you don't even need to tick each frame
do you prefer something along the lines of
if (doindex<dothing.length) {
dothing[doindex];
doindex++;
}
if i need to do stuff across frames, that's what update is for
That feels like a messy way to avoid coroutines
that's what the compiler is doing but it also carries along a lot of cpu memory fetches, allocations and more that it doesn't need to do
its actually slower than the same job
True, but I enjoy coding for readability and maintainability as well as efficiency
its basically thinking about ECS and going.... this is the EXACT opposite of ECS
in fact unity pobably started all this thinking looking at how to evolve coroutines and threading
I know people like them but just take the pain and stop it. use ECS
be powerful nerds of STEEL
Ha
fists of logic and google
making a short ECS exploration project has been on my to do list for a while now
I shipped a mobile game that did these horrible crimes and I knew about them at the time too:
-
moving mesh colliders (this is very old physx so you could have moving mesh colliders)
-
using invoke
this was 2010 on mobile 😂
60fps as well
I think we try too hard overall and should stop caring :D
- shrug. sounds slow
- GASP
Yeah. Move all to 2019.1, enable incremental GC and pool nothing
I mean I talk a big game for the right thing to do but in the end I do a lot of wasteful stuff as well because... there's just no time really and you get worn out being mr perfect code practise guy
Yea, I like to think "fix what is slow", not "fix what you think might be slow in theory"
love that too... I mean we pick a good starter algorithm usually so no optimisations are really needed. if they are I'm far more likely to time slice at the end with some kind of little manager gnome smoking cigs and going "ok mate your turn to run... who's next?"
its an easy fix
I will HPC# all later when unity's finished wondering why their nuts have been bolted
void OnTriggerEnter(Collider other) { //handwritten collision response }
moving mesh colliders are fine but they must be convex now. before they did not need to be, and would incur horrible performance .. I believe I only used it for raycasts anyway - wanted a one-sided raycast shape you couldn't move into but could move out of
it didnt incur horrible perf because it was basically just a few polys in a specific shape :)
I was lazy and let physx do my heavy lifting
hehe
Unity Coroutines need to be relegated to the archives if history, only to be used as an example of what not to do.
It would be nice if unity could implement awaiters for async to replace the coroutine yields and make people's transition to async easier, currently you have to make up your own or use a third party asset.
Maybe throw events?
Any Mac folks out here? Here is a build of Unity 2018.3 Mac Editor with PhysX 4: https://forum.unity.com/threads/physx-4-0-in-unity.634960/
any chance the unity team will look at this: https://feedback.unity3d.com/suggestions/physics-contact-modification
The PhysX SDK allows developers to modify contacts so they can: "... implement sticky contacts, give objects the appearance of float...
Yes, we will.
That's great news, any time frame? 😃
Yes, any time frame. Thanks.
lol
tbh, I'm afraid by the time that happens, it might be irrelevant to me :p
but would still be fancy to have it
this is one of the major downsides when you use Unity
I implemented physx contact modifications on UE4 in few days
yeah cpp
(yes I have public github fork of UE4 that has this if anyone is interested)
why is it not in master
I've only sent Epic PRs that they are likely to merge
its great though that they OSed
the unity source comes with a SUPER restrictive EULA
funny thing is that UE4 now actually got partial support for them but they only did half of the implementation and I'm fairly certain that they based it off my fork as they use exact same naming conventions on places where it makes no sense 😄
(they needed that for Fortnite so they just threw in a stub they needed for that internally)
I've extended their setup on my fork for newer ue4 versions too
only reason UE gets so much love right now is fortnite anyway
pretty much yeah
once that dies UE is back in the sack
well, they always evolve the engine based on their own projects
you gotta claim your share of Fortnite for that patch Olento 😃
ha
i really realy love unity
I only have two gripes with it
- move to .net core. please. now.
I actually did apply for their devgrants but I think I've trashtalked too much about UE4 on their discord to have any chance of getting that 😄
@lapis plaza come live near me. You can walk up to their HQ and tell them how much their engine sucks
I've also implemented fixed timestepping for UE4 and maintained nvidia blast for it
well, it's not all bad
it just doesn't work like I'd want
but no existing game engine does
unity has fixed time step by default but somehow under the hood some things aren't right and things stutter a lot
that's not the fault of the fixed timestepping code tho
interpolation is bugged
because interpolation is based on time.deltatime, which is spikey and jerky
technically yes but it's not even issue on the interpolation code itself but how deltatimes are handled
you can't really mess up interpolation code easily, it's fairly simple
with Physics.Simulate() you can go variable if you like FWIW, since Unity 5.6
yes but that makes it way too undeterministic
we could debate about physx determinism too 😄
it's not
but yeah, I'm hugely favoring fixed timesteps myself
it's just more consistent on custom physics
another is - could it be possible to simulate manually and override interpolation with our custom code?
that's what you have to do today if you want butter smooth physics on unity
that deltatime issue still makes me wonder
it has to be some inconsistency on how Unity delivers rendered frames
as Unity measures the deltatime itself just like every other game engine out there
Is interpolation based on average frame rates or last?
like, rendered frames get displayed at even pace but deltatime is varying
so this will make it jitter
It would make more sense if it was sampled off say 10-30* frames
yeah Olento your right, but we have no way to access the interpolation values in unity engine
there's been a few bugs in interpolation that I fixed in 201 7 - we were apparently using float instead of double in a few crucial spots, a mad russian hacker sent me an incredible repro that proved it I recall
you can smooth the deltatime but you need it still to react to sudden framedrops
I think it was broken on 5.6
at least people ranted a lot about it
Sample 30 frames should be fine if you really think about it
the code I fixed was like that since the beginning of time
hmm
btw I've tried smoothedDeltatime but it's not enough, I don't think it samples that many frames
If your game is running at 30 or under fps your game is going to look crappy anyway
it does help a bit but not enough
as in - I tracked it down back to when Joachim committed Unity 2.0 from svn 😃
you guys use perforce or git now?
you can make your own deltatime, and own deltasmoothedtime if you wish but you can't submit those values to the unity interpolation
or still svn? 😄
@lapis plaza til unity already implemented my idea lol
we're mostly on Mercurial actually
@pearl warren if you make those yourself, just step the physics simulations yourself
Didn't know smoothdelta was a thing
however the new ecs stuff happens on git
Yeah its great
yeah, I'm a fan of that
I only don't get why multiplayer is kept in the dark
I like to tinker with code
Speaking of packages, does the new post processing stack (v2) also add 15,000 shades to be compiled into your build like v1?
gives me confidence that if there's a breaking bug, I'm not helplessly at the mercy of Unity fixing them for me
Punfish - off topic I'm afraid
Can't tell you how annoying that is. Every time I have to rebuild a project post processing takes up an insane amount of time.
V2 is depricated sooner than later I think, it moved to SRP
in that other engine, I usually fixed minor bugs and just PR'd them as it was faster than writing details issue report and get anyone to react there for it for few engine versions
at Unity, I could only do that for few minor SRP bugs
yes i agree with Olento
Unity should def move to open source on github
with a restrictive licence or whatever
just like how the competition is doing it
you can keep those bits closed
my hopes are that they'd do slim DOTS engine core that they could share at some point
but
this would also require major licensing changes which Unity is not wanting to make for sure
altho this isn't as big of an issue now like it was on Unity 4 days where free side was totally limited
and knowing unity, if they even did that, it would be for Pro users only :p
this is funny btw
because if you watch any recent ECS talk from Joachim, he keeps saying Unity is giving ECS etc packages (c#) source codes to Unity Pro users
this has puzzled me a lot, like, doesn't he know the terms they operate under or is that some plan that has never realized for them?
because right now, almost all new package manager packages ship with c# sources
for all users
I really hope they don't do anything stupid and move the source access of those again to pro only because that was the mistake they did before Unity 5 and lost a lot of users to other game engines
(they limited all the useful engine feats to pro customers on Unity 4 and before)
that worked fine
i was on pro licence back then and still am
no right now they do give unity source
but only to big companies
that pay big
I'm on plus still
I wouldn't even need to be atm 😄
oh I'm now talking about things like ecs source code
Joachim has mentioned many times on Unite talks that c# source code is available to Unity Pro customers
when in reality it's available to all Unity users
yeah its just on git
actually ECS code is not
(in package manager, full sources)
kinda wish they had that on git because now I just maintain local git repo to see the diffs from version to another
noticed this on FPS Sample update that just dropped into github: HitCollision no longer uses Unity collision system for queries against moving colliders. For lag compensation server needs to do queries using different historical data and moving Unity physics colliders multiple times per frame is very inefficient. Now queries are handled using custom collision primitives and burst jobs. The structure of the collider and history data is still WIP.
that's.. interesting
wonder if they use this on megacity sample too now
that's what I want.
All I need are the spatial query stuff for my game. All the physics is custom anyway since it's a platformer
I don't see why a thing can't be simply simulated until more complex simulation is needed, such as 1000 ecs characters, but only the nearest ones have a full physx representation, etc
that fps sample update is cool, tempting to try and cut and paste all the ecs collider stuff into my project but I should probably hold off for official ecs physics 😬
could be that they use this as some proto platform for some of the systems on it
but yeah, really curious to see what happens with megacity if they deliver the project on GDC like they hinted they might
at the reveal, it looked like there was no collision at all for it
does megacity even need physics?
but if they have system for it now, they could setup one for it
well, you'd fly through buildings if you don't have queries
i guess i never thought of how they'd handle a public demo vs just a video presentation
for the movement they probably have naive RB physics integrator
like you can do thing that handles that in really small amount of code
for example, physx's vehicle substepping code has first order euler integrator that's like 20 lines of code
and yeah it doesn't really "need" physics but it would be nice touch to have collisions
even if it didn't even make collision responses but just turned the vehicle away from walls
i think i kinda assumed that you would just go through buildings but now youve gotten my hopes up for basic physics
and since they have basic setup for fps sample now, they could reuse it on megacity too
but who knows 😃
oh right, that new system was only for dynamic collisions
The mega city demo had no physics when they showed it and you could fly through buildings
hm
@manic portal If you use Houdini I have V-HACD plugin for it with export and setup script for Unity. I wrote it around 3 years ago to have engine agnostic version.
I didn't looked at it lately but it still works and have many additional things you will not find anywhere else.
That sounds really cool, is the plugin freely available or?
it might be a nice share for @tardy spear if he hasn't seen it and it has source. All things help ofc
The additional features part is interesting
Regarding "flying through buildings" I don't really think it's a problem to fall back to local monobehaviour game physics + local representation as you move through the world as an interim solution.
in 2015 I generated a 5 mile wide city / env which did this fine with the same granularity as the megacity demo. The differences were that I simply pooled everything in sight, used umbra on proxy vis and used a basic grid (not even a quad tree). Ran around 400fps on my 780 ti back then, so the visual aspect of megacity could always be approximated but what interests me about megacity's physics is that it'd lead to much more DYNAMIC stuff, such as destruction and so on........ physics in this case are usually baked or even an animation so it's definately going to be about how dynamic or even how unique the visuals are (mine did not stream, but pooled)
What excites me about ECS/DOTS physics is just how dynamic this stuff could be.
I don't share my stuff openly anymore, but I can add collaborators to my private repo.
I'm trying to implement a pause button in a VR game which relies heavily on physics. The most simple solution would be to have Time.scale = 0, but .... I would still want to have a physics based UI during a paused game. One approach I've seen is to grab the velocities of rigidbodies and add .sleep() to each object. But I have a feeling this would also cause quite a few glitches and doesn't solve the problem of pausing all spawners, animations etc.
Is there a third option?
Is the new multi-scene and multi-physics functionality in 2018.3 capable of handling such a case?
why not set all rigidbodies to iskinematic = true?
animations can be frozen too by disabling the animator i think
about your spawn script, well thats simply by having a check there if the game is paused?
I can see several edge cases where this might not work as expected (the player obviously wants the same effect as hitting a pause button on remote), so things shouldn't get reset, just freeze. I have some objects that are spawned and use an animation, so disabling and enabling the component would just reset the animator controller.
even setting the animation speed at runtime just resets the FSM of the animator
if you disable an animator on a skinned mesh renderer the state will be frozen, enable it again animator will go on where it left off afaik
about multi scene physics, i suppose you can seperate your physics UI like that, i'm not sure if there are specific time scales.
You also pause your particle effects etc
it's going to be hard to get this right.
So the animator pause with speed works from script (I've just tested it quickly by typing in the editor ... wrong approach). But as you mention there are so many things in a scene that depend on the time scale, like particles, audio etc.
so it's setting one value vs. writing a ton of sripts to hold and release values , with many potential problems
I haven't found so far anything concrete about the multi scene physics(since it's a new feature), but if they could have separate time scale that would be ideal. I could then have all the UI buttons, knobs and sliders on one scene and all the game play objects on another.
fun little thing I also found was that as SteamVR keeps tracking, using just the Unity XR also freezes the controller tracking when you set Time.scale to 0 😃
😦
pausing audio works too
and particles can be paused too
it's a lot of work i agree
i dont know about multi physics scene time scales
i havent found something in docs so far
I'm aware this is doable step-by-step, it's just such an overhead for something that could be setting 2 parameters.
I think i saw it requested on the forum somewhere actually
I don't see a way to set physics time scale per scene so far
so i doubt this is an option for you
Well .. this would be super useful for many VR projects, where you want to slow down, or stop time and expect the player to still interact with the scene. Doing something like bullet-time means that your player moves with some crazy speeds and adds enormous forces to the slowed down objects. So again something that could be handled with one variable requires a really complex system of clamping the interactions of the player., dealing with all the edge cases.
I'm wondering if recreating the physics of the few buttons I have wouldn't be easier at this point 🤔
nevermind they just kicked out the feedback from their website -_-
oh wow ... they removed it completely? 😕
@thin halo just disable the automatic physics stepping and call physics.simulate on your own
If it is a desktop vr game, you could do that on each update anyway to get solid 90Hz physics that match your gameplay
Could you clarify? How would a set-up like this work?
that autosimulation is enabled by default and Unity steps your physics updates automatically
but you can turn it off and run your physics steps on yourself
Unity also uses FixedUpdate for physics stepping by default but if you do 90Hz VR game, you'll get more responsive physics if you only do one Physics.Simulate(Time.deltaTime); on Update
if your own gameplay scripts rely on physics, make sure your physics update script runs first by either altering the script execution order (https://docs.unity3d.com/Manual/class-MonoManager.html) or by manually modifying the playerloop to run your physics step right before Update (this is more complicated)
@thin halo
so with a setup like this, to pause the physics, only thing you have to do is make sure your physics update script doesn't run that Physics.Simulate while paused
that's it
from 2019.2.0a7 release notes: Physics: Upgrade cloth lib from deprecated PxCloth to NvCloth.
noice... apparently just a surface change and refactor more than perf
it's different lib
Nvidia Cloth has replaced PhysX Cloth
and this is basically a required change so we can eventually get PhysX 4.0 which doesn't have the old cloth lib
but it's a good to update it to more recent lib anyway
for example UE4 moved to NvCloth ages ago
apparently NVcloth is simply PhysX cloth fork
as long as it does cloth well, they can call it Shirley for all I care 😛
@pearl warren it's nvidias new cloth lib, it's replacing Apex Cloth
nvidia deprecated the whole Apex set like year or so ago, including Apex Clothing, Destruction, Particles and Turbulence
new cloth solution is NvCloth, new destruction solution is Blast, new particle thing is Flex and turbulence is replaced by Flow
afaik, yes
was looking at upcoming GDC talks, spotted this: https://schedule.gdconf.com/session/physx-4-raising-the-fidelity-and-performance-of-physics-simulation-in-games-presented-by-nvidia/864958
but if they don't put that vehicle talk behind paywall, I'm genuinely surprised :p They tend to do that always as these seem to be the talks people want from physics talks
only exception I can remember to this for recent years have been the rocket league physics talk from last GDC
There is apparently a new Vehicles physx sdk for Physx 4.0
will have to see how it goes really, no guarantee it'll be all that useful
@pearl warren I doubt it
I've read their changelogs almost religiously, haven't seen anything major new for vehicles
that's what triggered my intrest
ah
it's probably something that's still coming up
wonder if it's totally separate SDK now
I hope so
also hope it'll not be as messed up thing as physx 3.x vehicles have been so far
that thing would require a rewrite
it's not just Unity's implementation
even if they exposed everything, it wouldn't be great
there are just so many things wrong in their vehicle code
I'd rather have no vehicle code in physics engine internals personally
but rather things that let you implement better vehicles easier on your own
I don't really know any physics engine that has great vehicles out of the box
they are just wasted resources IMO
that;s quite sad really
i would disagree
good vehicle code can help many developers
that I don't deny
besides it should not affect performance of the physics engine
unless you actually use them
I just don't want to see stuff like that in the physics engine core if it's half baked implementation like I've seen on every physics engine I've seen vehicles at so far
Like Character Controllers, Vehicle code is typically going to ship in prototype state, because they're super unique really, to each game.
the nvidia CC is recognised by nvidia as a prototype tool, a starter library for characters. But Unity just implemented that way back when as a first class citizen (which wasn't that good as you know). Same for wheel collider. Same rationale from both companies.
I currently have rolled my own character controller which is just a capsule and normals, and it does everything I could ever want. It's somewhat a special hack but it allows to go from physically correct to arcade in response
well... there's recognized good ways to do things and recognized bad ways. I don't think it's asking too much they do it the good way, if at all.
not even a big file, just one script. stuff is simple if you know what your own game needs
well my grandfather was a royal engineer
and he used to say stuff like "don't do a job if you won't do it well" and "no good comes from a bad start"
which kind of makes sense for an engineer in the army back then
haha
yes
thing is young hippo looked up to him and took these lessons
the pogo sticks unity uses for wheel colliders are just bad
lol
They are alright but I have way better vehicles just moving a rigidbody and knowing normals. The rendered representation doesn't match the physical one
so the suspension's faked a tad but it's super usable etc
I just do all my physics like that I guess
someone shared a pic somewhere of what someone did for their vehcile
and i wish i still had the pic
basically they just put it on 4 spheres lol
lol ye olde spherecar
but it worked better than the default lol
the key to all this stuff really is getting the movement right, it doesn't matter if its a sprite or whatever
then you just get good info from the env and off you go, give it a good old rub
yes, only problem with spheres is, it's just as happy to roll sideways as forward 😃
Sounds sort of fun
I recall a contract project I worked on when I was just starting, and we still used Torque.
I tried for hours using the sample vehicle to get it to play nice with my Fuzzy logic driving AI.
It bounced once, twice, and then into infinity and hard crashed the entire engine.
We faked everything after that. Vehicles, like a lot of character controllers, are a special breed of RYOC
Can't agee more if I tried :)
Obviously for a Forza thing, that's actually quite a bit safer, you can stay in sim land, like Edy does
Gta's cars are really probably just way simpler than people expect
I've tried some car controllers in unity that were actally pretty nice