Hi,
I want to write track scaling for my track assembly, but I'm having problems with scaling the tracks. For straight tracks,
it's simple. You just have to scale only one axis to extend the length, but for curved tracks it is quite tricky, since, if you
scale for example the X axis and if the track is 90 degree curve ( see below ) , the other end along the Y axis becomes distorted.
A simple solution will be to just scale the whole track by the same number along the 3 axises for curves, however I am tempted to extend the cure and straight tracks length using SetModelScale or EnableMatrix. I think the latter does not extend the
physics model so I better use the first one.
How can I properly scale the physics object of the physics entity in one axis or multiple axises ?
https://files.facepunch.com/forum/upload/114065/169c39ff-133e-4911-8c69-28da16022f82/track90.jpg
Sadly, scaling the physics object of an entity is only possible using SetModelScale and that scales it the same on all axises (axes?). I have been following your progress on this tool, and it is great. However I think scaling is something you will only have problems with and probably is not worth in the long run. Working in Source can be painful when it comes to physics stuff.
Indeed, thank you for sharing this information, sadly I need the physics object scaled if I intend to do this. Then I happen to notice these resizing functions. They actually do great according to client related stuff that is indeed not the case here.
Thanks !
Yeah, you can scale stuff clientside on any axis, but not serverside, so no physics. The solution would be to make a custom entity and use custom collisions and stuff, but that is alot of work, if it even would work at all.
Thanks !
I intend to ditch this if the physics model cannot be scaled server side natively. If that is the case I'm sure that every Gmod update will potentially break my addon.
I've tried finding a non crashy method which actually works flawlessly.
Answer: There's none I know of.
There's nothing wrong with recreating the physics object with new bounds that you scale yourself. The only problem is you can't do this generically for any entity since there's no way to detect what type of physics object an entity has, but if you control the entity classes, then you can hardcode the recreation method. I would stay away from SetModelScale and network your own scalar to prevent running into networking limits and physics unpredictability. Use Entity/EnableMatrix for model scaling.
SetModelScale just recreates the physics object internally. There is no method to reuse a physics object and "resize" it - the internal mesh will always remain static.
Use Entity/EnableMatrix for model scaling
But in the wiki sais this is client side for rendering the model. I need to scale the track pieces along the curve. How can I do that with a custom function ?
That's just for rendering. On the server, you can recreate the physics object by scaling PhysObj/GetMeshConvexes's mesh and sending it into Entity/PhysicsInitConvex (one convex) or Entity/PhysicsInitMultiConvex (multiple convexes). Unfortunately, this is really slow - the faster solution would be to trace against a dynamic PhysCollide like the example here but there's no function to scale PhysCollides or create one from a table.
I've actually managed to resize physics objects a few times.
There is even a tool in the workshop for that, and it works half/half.
But there is no way I ever managed to make it not crash in certain cases.
Resizing stuff too big or too small will always result in a crash.
Damaging a resized object CAN result in a crash for some reason, for me atleast.
Getting out of map, just slightly with my resized prop, instantly crashes.
This is was I experienced.
It's not worth the risk.
Only if you MANAGE to ALWAYS stay in world and never get to big or too small, even then, it crashed for me when damaging it on certain angles.
I was out of ideas, doesn't mean there is no way.
Sorry, you need to Log In to post a reply to this thread.