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"

line trace question

Hi there community, i made this line tracing for a shooting game, and at this point id like to make the line disapear after certain time(5secs).

I know there is a way to make it, but i cant make it work.

Here is the part of the code , maybe its the way its structured or something im clueless about this right now.

This is in the .cpp part, dont know if its here or somewhere else that i have to change it.

 void AWeapon::Instant_Fire()
         const int32 RandomSeed = FMath::Rand();
         FRandomStream WeaponRandomStream(RandomSeed);
         const float CurrentSpread = WeaponConfig.WeaponSpread;
         const float SpreadCone = FMath::DegreesToRadians(WeaponConfig.WeaponSpread * 0.5);
         const FVector AimDir = WeaponMesh->GetSocketRotation("MF").Vector();
         const FVector StartTrace = WeaponMesh->GetSocketLocation("MF");
         const FVector ShootDir = WeaponRandomStream.VRandCone(AimDir, SpreadCone, SpreadCone);
         const FVector EndTrace = StartTrace + ShootDir * WeaponConfig.WeaponRange;
         const FHitResult Impact = WeaponTrace(StartTrace, EndTrace);
         ProcessInstantHit(Impact, StartTrace, ShootDir, RandomSeed, CurrentSpread);
 FHitResult AWeapon::WeaponTrace(const FVector &TraceFrom, const FVector &TraceTo) const
     static FName WeaponFireTag = FName(TEXT("WeaponTrace"));
     FCollisionQueryParams TraceParams(WeaponFireTag, true, Instigator);
     TraceParams.bTraceAsyncScene = true;
     TraceParams.bReturnPhysicalMaterial = true;
     FHitResult Hit(ForceInit);
     GetWorld()->LineTraceSingle(Hit, TraceFrom, TraceTo, TRACE_WEAPON, TraceParams);
     return Hit;
 void AWeapon::ProcessInstantHit(const FHitResult &Impact, const FVector &Origin, const FVector ShootDir, int32 RandomSeed, float ReticalSpread)
     const FVector EndTrace = Origin + ShootDir * WeaponConfig.WeaponRange;
     const FVector EndPoint = Impact.GetActor() ? Impact.ImpactPoint : EndTrace;
     DrawDebugLine(this->GetWorld(), Origin, Impact.TraceEnd, FColor::Black, true, 10000, 10.f);

Product Version: Not Selected
more ▼

asked Apr 07 '15 at 04:45 PM in C++ Programming

avatar image

14 7 10 14

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

1 answer: sort voted first

That's the ShooterGame Code i guess.

If you mean the DebugLine, then yes, it is at the bottom of your code snippet here.

You will want to change the "true" to "false" since this is for "persistent" and change the 1000 to your lifetime.


more ▼

answered Apr 07 '15 at 04:51 PM

avatar image

6.8k 333 185 470

avatar image Folgad0 Apr 07 '15 at 04:57 PM

ill try it , thanks for the quick reply :)

avatar image Folgad0 Apr 07 '15 at 05:01 PM

Worked thank you

(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