Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

LineTraceMulti strange hit location/results

alt text

alt text

I'm fairly new to c++ in UE4 and I'm already running into some problems with a line trace. This trace appears to be hitting like up in the sky versus straight forward from the camera like i would want it to. My suspicion is it has something to do with ShootTraceEnd. Im just not well versed enough to identify whats causing it. This is a pic of the original blueprints i used as a reference for the code. Also a pic of the angle the bullets are shooting at, and ultimately the direction of the line trace.

edit: This function is being called from blueprints and ran on server as well. Thought I should mention this. alt text

alt text

Product Version: UE 4.21
untitled.jpg (428.2 kB)
untitled1.jpg (538.2 kB)
untitled.jpg (97.6 kB)
untitled1.jpg (81.8 kB)
more ▼

asked May 17 '19 at 06:24 PM in C++ Programming

avatar image

64 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

End point need to be in world space too and camForwardVec is local space, so you need to add ShootTraceStart to ShootTraceEnd to apply offset to start position.

more ▼

answered May 17 '19 at 08:26 PM

avatar image

36.6k 931 169 1111

avatar image Plzwork1234 May 17 '19 at 08:59 PM

that surprisingly did not fix it because you were right, I completely forgot to add the camera location which was right in front of me in the Blueprints. But yeah oddly enough, the bullets are still going upwards on the exact same line as the picture i posted.

Could this whole thing being run on server effect any of this? Cause spread and camForwardVec are local variables in a function thats being run on the server? Is it possible these local variables are not being replicated or something funny like that?

avatar image Shadowriver May 19 '19 at 12:55 AM

What is Pitch varbale? You nto taking it from camera and Pitch is up and down rotation

Whatever it run on server or client depends on what is calling that function, generally this should be done on server to avoid hacking

avatar image Plzwork1234 May 19 '19 at 05:04 AM

Pitch is from a tick event ran on the server. The pitch from Camera->GetworldRotation does not replicate for some reason so I had to set pitch separately on a server event. Since i posted this, ive also duplicated everything from this function into a c++ function that runs on the client, and confirmed that it does work properly. So I may have come across a bug potentially.

avatar image Plzwork1234 May 19 '19 at 05:07 AM
 FVector AFPSChar::ShootLineTrace(FVector traceStart, FVector traceEnd)
     LineTraceHit = UKismetSystemLibrary::LineTraceMultiForObjects(GetWorld(), FirstPersonCamera->GetComponentLocation(), (FirstPersonCamera->GetComponentLocation() + (FirstPersonCamera->GetForwardVector() * WeaponInventory[InventoryIndex].ShootRange)), ShootTraceTypes, false, ActorsToIgnore, EDrawDebugTrace::ForDuration, HitResults, true);
     if (HitResults.Num() > 0)
         SpawnBullet((TPGun->GetSocketLocation("Muzzle")), UKismetMathLibrary::FindLookAtRotation(TPGun->GetSocketLocation("Muzzle"), SelectVector(HitResults[0].ImpactPoint, HitResults[0].TraceEnd, LineTraceHit)));
         return SelectVector(HitResults[0].ImpactPoint, HitResults[0].TraceEnd, LineTraceHit);
         return FVector(0.f, 0.f, 0.f);

this is the function ran on the server that isnt working. The line is still being fired upward like in the 3rd picture above

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question