Visualized LineTrace (mini library)

Sprites, textures, sounds, code, and other resources belong here. Share and share-alike!
Forum rules
Before posting your Resource, please make sure you can answer YES to any of the following questions:
  • Is the resource ENTIRELY my own work?
  • If no to the previous one, do I have permission from the original author?
  • If no to the previous one, did I put a reasonable amount of work into the resource myself, such that the changes are noticeably different from the source that I could take credit for them?
If you answered no to all three, maybe you should consider taking your stuff somewhere other than the Resources forum.

Consult the Resource/Request Posting Guidelines for more information.

Please don't put requests here! They have their own forum --> here. Thank you!
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1117
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)

Visualized LineTrace (mini library)

Post by Jekyll Grim Payne »

A mini-library / example that adds functions to draw a series of particles between two coordinates, and a version of LineTrace() that is visualized with those particles.
https://github.com/jekyllgrim/Visual-Li ... zscript.zs

The functions are static, contained within the JGP_VisualTrace.

Code: Select all

FireVisualTracer(Actor originator, double dist, int flags = 0, double partDist = 1, int partTics = 1, color partColor = color("00FF00"))
Fires a LineTrace from the originator and draws particle along its length. Parameters:
  • originator — the actor the trace originates from. If it's a PlayerPawn, it'll fire fire from its eye height (matching the position of its crosshair), otherwise fires from actor center.
  • dist — the distance of the trace
  • flags — same flags as LineTrace() uses
  • partDist — distance between particles
  • partTics — how long the particles should exist
  • partColor — the color of the particles.

Code: Select all

DrawParticlesBetweenPoints(vector3 startpos, vector3 endpos, double partDist = 1, int partTics = 1, color partColor = color("00FF00"), int flags = SPF_FULLBRIGHT|SPF_NOTIMEFREEZE)
Draws a line of particles between two points. FireVisualTracer utilizes this function. Parameters:
  • startpos — coordinates of the first point
  • endpos — coordinates of the last point
  • partDist — distance between particles
  • partTics — how long the particles should exist
  • partColor — the color of the particles.
  • flags — same flags as A_SpawnParticle uses. SPF_FULLBRIGHT and SPF_NOTIMEFREEZE are enabled by default.
Comes with two examples: JGP_TraceFromFace (an item that will fire a linetrace in the direction its owner is looking) and JGP_ZombiemanWithTrace (a Zombieman that constantly fires a trace wherever it's aiming).
User avatar
Nash
 
 
Posts: 17481
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Visualized LineTrace (mini library)

Post by Nash »

Well shit, I needed this!
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: Visualized LineTrace (mini library)

Post by Sir Robin »

Ah, and I just spent my afternoon writing something similar

Ok, I got the latest from GitHub, spawned a few zombies, watched them walking around looking for me, killed one, then got a div by 0 crash: line 52 from 35 from 111

Return to “Resources”