Comparing two consective hit results (frames)
Hello, So i have a FHitResult working. I have a reliable hit detection method. However my method is working for every frame. I would like to be able to compare the first Hitresult with the next. If they are the same, i don't want to do damage, however if different then deal said damage. I have tried creating a FString array, which i then add the HitResult.GetComponent()->GetName()) on one frame. Then on the next frame add the next hit result. Then comparing the two like if(Hitresult[current] != HitResult[before]). But it won't work. Sometimes it will crash on collision too. Please any help would be greatly appreciated
asked Jan 24 '16 at 06:27 AM in C++ Programming
It may crash when the GetComponent return null. Instead of using FString, you can keep a reference on the object you collide (so have an array of Uobject* or Uactor* or Uactorcomponent*) to make sure you do not have a conflict with the names. When you will make the check to see if a collision already happened, you should use IsValidLowLevel () to be sure that the object/actor/component has not been destroyed during this frame. If it is the case, remove it from your array. Eventually, the best will be to use an array of Tweakobjectptr. This special pointer will tell you if the object is being destroyed AND if the object has been destroyed.
answered Jan 24 '16 at 11:39 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here