|
Post by MonstaWolf on Mar 16, 2016 12:32:45 GMT
Hey everyone. I'm quite stuck on how to do this, and after days of trying to make it work, I decided to ask the awesome people here. So, in my game, I have these cool "crash scenes" which are physics-based. But, that's beyond the point. When you crash, parts of your car can fall off, and I'm trying to make it so that when your car resets all the parts are back on it. It typically works well, but it seems that the faster the car is going when it resets/the more it's moving, the more inaccurate the parts are. Here's a screenshot below of an example of what happens (The bumper spawned in the wrong position, and if you look closely, the trunk/spoiler is too). Screenshot
After some experimentation, I came to the conclusion that it has to do with the motion of the car. If the car is still/close to still, it spawns properly. If it's moving/spinning, they will most likely spawn in the wrong position. By the way, I'm also using a script to reorient the car if it's upside-down, but that seems to not affect it at all. Also, I'm using iPositionReset to reset the parts. Should I be using a different function, or is it something else? Tell me if you need more information.
|
|
|
Post by TinSoldier on Mar 16, 2016 21:23:35 GMT
I think you answered your own question.. if you were to save the vehicles properties ( velocity etc ), then set the velocity to 0 to freeze it ( just for one engine cycle ), on the next engine cycle apply the reset, then on the 3rd engine cycle, re-apply the velocity. I'm thinking this should correct the issue. If the parts still come out misaligned then i would say the physics are doing this after the parts are reset, think of it like wind blowing something, once reset it's properly aligned but immediately the wind is blowing again and moves the part out of alignment ever so slightly. Maybe this is a issue like the fast moving bullet... When a bullet is moving too fast, it appears to pass through the target and fails to register a hit.. What actually is happening is, the bullet jumps from a position in front of the target to a position beyond the target . This happens because the bullet has to move from point A to B to point C at a certain speed ,and the engine its self only runs at a certain speed, to keep the bullets position accurate, not every milometer of it's travel path can be processed on every engine cycle, so the bullets position jumps from point A to B to C passing over the in between points on the path. I don't know if that bullet issue has anything to do with your issue, but i jumped to mind because it's a processing speed issue with the engine, maybe you issue is being effected by the engines performance too, and the fix requires some creativity to correct.
|
|
|
Post by Power Supersport on Mar 16, 2016 22:00:23 GMT
Awesome people, dude! Thanks! You're one of them! Is your damage system scripted? I mean, are the parts' location controlled by script before being deattached? Or do you use joints? I am interested into your damage system... Can you provide a little bit from your script? I mean specificly the part meant to control the reset and the deattaching...
|
|
|
Post by MonstaWolf on Mar 16, 2016 22:04:54 GMT
How would I go about setting the scripts to work on individual cycles, though? I can easily figure out how to make it do what you mentioned, but I don't know how to split it into individual cycles. If I knew how to do this, it would help me fix a few other problems, too.
|
|
|
Post by MonstaWolf on Mar 17, 2016 15:10:01 GMT
Power Supersport The damage system is a bit complicated. I originally created it back when I had no knowledge of scripting, and have now improved it with scripts. Each part is held on by a joint, and under certain circumstances (aka, you hit something), the part will fall off. I'm working on making it so that if you only get tapped/lightly hit, the part will only hang off instead of falling off. Would a script be more reliable, or would the parts lag behind the car?
|
|
|
Post by Power Supersport on Mar 17, 2016 16:36:36 GMT
I never used joints... Because they aren't that much reliable... And when you want to reset the joints are the things that cause the mislocation...
|
|
|
Post by MonstaWolf on Mar 17, 2016 19:09:00 GMT
Oh... what function should I use, then?
|
|
|
Post by Power Supersport on Mar 17, 2016 20:18:17 GMT
Well, it may be complicated for you... The bumber and all parts are rigidbodies (can have connected skinmeshes)... They are using the orientation and location of the car as an anchor... Once they collide with something they stop using the car's loc and rotation and they use only the physics... Something like that... You can think of a method too...
|
|
|
Post by MonstaWolf on Mar 17, 2016 21:18:30 GMT
I tried to script it, but the parts all acted as if they were attached by a rubber band. When I moved the car, they would deattach, and when I would stop, they would slowly move back into place.
|
|
|
Post by Power Supersport on Mar 18, 2016 10:53:45 GMT
Do you have any video footage? And if not fo you plan to post one? So I can see and tell you what to do... Because I never needed such system and I don't have any experience in it...
|
|
|
Post by MonstaWolf on Mar 18, 2016 13:01:10 GMT
Video footage... I may be able to get. But, I don't think I will need to, as I successfully got it to work how I want
|
|
|
Post by Power Supersport on Mar 18, 2016 15:50:43 GMT
That's what I like in you! Well done... BTW, most of the errors I get, I fix them after some time... Just give it some tries, some different ways etc. and eventually it will work...
|
|