Help with custom trace function?

I am attempting to force a line trace using a vector direction that does a check for dinos or players and applies a certain type of damage if an impact is detected on primary fire function. Either the trace isn’t firing, or the damage isn’t being applied. I need help as to how to do this.

There is a pawncheck script and a dinocheck script that each only run if there’s ammo in the clip.

There a a few areas where this goes wrong :smiley:

  1. Afaik you need to enable the input on for the playercontroller holding the weapon on event begin play or you input events will be ignored.

  2. Your trace is currently tracing along the ground. If you want it to trace from the center of the screen you will have to get the playercamera location and start your trace from there. For the endpoint you want to get the cameras forwared vector, multiply it by your desired range and add that to the camera location.

  3. “Apply Point Damage” will only work if called from the server(the little computer on the top right of the node indicates this). Input event will only fire on the client side though. What you want to do is call a run on server event from the input event to switch over to the server side and call “Apply Point Damage” from there.

I did a little example for a basic setup that should do what you want(you just need to add the damage part and your ammo handling):

Quick note here: The PlayerCameraManager only exists client side, that’s why we need to get the locations on the client first and pass them to the “run on server” event. It’s probably even better just get the location of the camera and calculate start and end position all on the server, so the range cant be tempered with(realized this after making the screenshots).

A few tips for debugging such problems:
You can add “Breakpoints” on graph nodes. This will help you to see if an even gets fired or not and also what the current variables are. You can also “Step” through the execution from breakpoints.
Another thing that helps with debugging is putting in a few print string nodes here and there.

I played around with the above example a bit and noticed it would trace through walls. That’s because the “PawnMeshTrace” channel does not get blocked. The “Weapon” channel should be the right one, but you will add a cast to pawn to verify you hit a pawn. Heres an updated example:

I also uploaded the blueprints to my little example collection on github here: GitHub - Mezzow/ADKTutorials: Tutorial/Example Blueprints for the Ark Survival Evolved DevKit</tit

Ok I figured out all the coding. Now it’s just not returning any values.

You just create a custom event, then click on then event node and you will see a details panel at the left side. Set the “Replicates” setting to “Run on Server”. This will replicate the event from client to server.

I have the on play event. I have the on fire event. I have the serverside ran trace function and all matching functions, but I ran it as a capsulecheck. I might change it back to a line trace. I even tried the blurb with the string and it isn’t returning anything. This was all entered into the weapons eventgraph.

Hey something went wront with your attached screenshot. But if you are testing in non dedicated mode, make sure you add a delay node after event begin play like so:

This is sometimes needed, im still not sure if this is just an editor problem or not, but it won’t do harm to add it.

These are the images I was trying to post.

I added the delay into the first one. Gonna test it real fast.

I tested the delay, and the weapon stopped doing the fire animation, and was also not returning any results for damage being applied to the dino I was hitting with it, nor using the string output command was it showing me anything.

I added in a function to show the fire animation and it caused the dev kit to crash.

If you want the default firing to still trigger click the input event node and uncheck “consume input”.
I just realized you are trying to set this up on a melee weapon, so there might be a few things that need to be modified.
Does your trace return anything?
I’ll have another look at this tomorrow if you haven’t figured it out until then.

So, I reconstructed the weapon using a pistol as the base, and modified the damage from there.