![]() The reasoning behind this is that anything to do with physics, in which I include Raycast, is supposed to happen on FixedUpdate as that is the "physics frame" as opposed to the "GUI overlay frame" that Update is. Take this with a grain of salt as I have not actually run any tests of any sort, but I think you will have to move it to FixedUpdate. Unity's own docs for Ra圜ast never mention this, but given the state of Unity's documentation, the fact that it never mentions it is hardly conclusive. I find people claiming it's better if you put Physics.Ra圜ast() calls in FixedUpdate() instead of Update(), but that seems like a drastic measure as FixedUpdate is a precious resource I should avoid using, and the rest of my logic about what to do with the raycast is too "expensive" for FixedUpdate() and needs to stay in Update() so it's going to make the programming more complex if I putthe raycasts in FixedUpdate().ĭoes anyone have good experience with Physics.Raycast() hitting ship parts and know whether or not this claim is really true (that you need to put the raycasts in FixedUpdate() for them to work right?) That's a major undertaking to make that change for my mod and it would be horrible if I went through the work only to find its a red herring. ![]() I've tried googling about it and it seems to be that people have trouble with Raycast hitting moving parts and it has something to do with the exact timing of when you call Physics.Ra圜ast(). The problem seems more pronounced when the ship is in motion (I have a laser on the ship aiming at another part of the same ship to measure the distance between them as an Infernal Robotics part moves them farther apart, and when the ship takes off the erroneous "penetrating" raycasts start happening more frequently than when it was on the ground.) Note, this is NOT (I don't think) a problem with the layers because it hits the SAME part for one or two Update()'s, then in the next update it passes right through it, then in the next Update() it hits it again, then a few updates later it starts passing through it again, and so on. ![]() It works fine for ground terrain or KSC buildings, but when aimed at ship parts it works intermitently. Unity's Physics.Ra圜ast() doesn't seem very reliable when it comes to aiming the ray at ship parts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |