Distance to problem?

Hi CO,

Hope all’s well mate!

I was wondering if i could pick your brains a tad to see where I’ve gone wrong with my initial version in the hope of understanding the best way to develop BP’s for the future.

I know your highly professional looking, elegantly coded and efficient BP that most importantly worked every time was a massive improvement over the way I very amateurishly and manually coded mine.

However, could I ask as I need to also develop a version that works using a single target location or trigger box in one room that needs to be found 4 times, then again the player has to find a different target 4 times in a second room.
Before finally going back to the first room to find the first target once then the second target in the second room once.

Would the amateur hour BP I originally developed be able to do this correctly, as I don’t want to mess with yours and am hoping it’ll save us both some time.

I’d really appreciate your help and am very eager to learn where I’ve gone wrong and how to sort of optimise stuff correctly.

I apologise for being a real pain and genuinely really appreciate all your very kind help.

This the code I’m using to set the trigger location within a variable, I do this after moving the first trigger in to place, I’m not sure if this would be better set from the outset of play using OnBeginPlay, as it doesn’t change until the player moves into the second room where it’s updated to the location of the second trigger.


I have to use multiple triggers that are separately moved into location so they don’t all fire off when the player reaches the target location.

I then ultimately use this code to calculate horizontal distance to trigger (just thought it’d be more accurate and logical to discount vertical path, not sure if this is correct):

I’d really appreciate your advice massively as I’m trying to learn and you’ve been an awesome source of both help and tbh inspiration in all honesty.

Hey :slight_smile:

What you have here looks fine, does it not work?

I wouldn’t worry about cancelling Z when finding distance, I think the difference is tiny.

It seems to work, but I can’t really check to be certain that the numbers for distance that it’s chucking out are correct?

Could you recommend a way perhaps?

Just get near to the mark and hit the key, you’ll know if it’s right because it will be almost nothing. The math looks ok :slight_smile:

Thanks loads!

I couldn’t have done it without you!

1 Like

It’s only me, unfortunately with yet another question, although hopefully a quick one:
From this position in the thick red outlined trigger box, the distance to the thinner outlined trigger box in front, I’m getting a reading of 180.55, each trigger box is 100 x 100 does this sound correct?

Seems like its a lot more than it should be?
XYZ co ords are;
First trigger (thick outline): -115, 67, 115
Second Trigger (thin outline): -115, 247, 55

I’d really appreciate your help as it seems to be the last hurdle.

You can measure the distance between objects in top down view by clicking middle mouse button:

Screenshot_3

1 Like

Cool, I’ll give that a shot!

I’m still having a strange problem with this unsure what it is?

The actual distance from a 40uu cubed trigger (based at -120, -90, 90 to the target trigger box a 100uu cubed trigger box based at -115, 247, 55) is 340 uu.

Having manually positioned the player in the trigger I get the following readings using my BP:
Round 1) 300
Round 2) 314
Round 3) 288
Round 4) 297
Round 5) 171

The first 4 are acceptable given it’d be difficult to position the player in the exact same spot every time but the last is not, it’s way off.

Moreover my BP, although very amateurishly designed uses repetitive chain of cascading triggers, it’s only repeated 4 times, so why does it result in 5 tries?

I’ve attached the BP in separate bits in the hope that it’s understandable, but it’s honestly driving me up the wall as to why the last distance reading is wrong?

What am i doing wrong, please help Clockwork mate!

Overall BP, bit big and a little difficult to understand but just to give you an idea:

I’ve broken this down to make it easier to follow:
First bit:


Second Bit:

Third:

Fourth:

Last bit:

I’m REALLY SORRY for involving you in this nightmare, but would really appreciate some advice

Should I reset the distance variable each time, this seems a bit silly as I don’t understand what could be changing it or even corrupting it?

For the first room it’s only the 5th attemot that’s out of whack.

However for the second room, which follows a similar structure bp it’s worse as the 3rd and 5th attempt provides a wrong reading.

I’m going out of my mind trying to figure it out

Delta

You’ve managed to produce ‘procedural’ code, even though the engine is trying to guide you into an ‘object orientated’ path. You see that repeating pattern in the picture of your code?

Screenshot_1

That’s the cue to put it in one object, with four different parameters. This is the danger of using the level blueprint.

It’s totally un-debuggable by anyone other than the author I’m afraid.

The only thing I can do is get you to give me a short précis of the current game goal ( no extensions added later ) and I can write you something again, but that’s about all I’m afraid.

1 Like

Hi CO,
The game has two rooms, the player has to find a trigger 4 times from different locations in the first room before moving to the second room where they need to find another trigger again 4 times.
Finally they go back to the first room to again find that first trigger then they are moved to the second room to find where that trigger was to complete the game.

if they can’t find the trigger I’d like them to press a key from their current position (where they think the trigger is) which outputs to screen the distance between where they are and where the trigger actually is.

I’M REALLY VERY VERY SORRY for all the hassle

So only 2 things to find?

Are the starting points random, or are you placing something for those?

That’s right:
There’s only one thing in each room to find, with 4 specific starting points that are not random:

So:

room 1: find 1 target 4 times, each time from a different location in the room, then

Room 2: find 1 target again 4 times, again each time from a different location.

Finally:

A) Return to room 1 and in a completely different position to previous times to find the same room 1 target once.

B) Return to room 2 and in a different position to previous attempts in this room to find the same room 2 target once.

End game.

Sorry, will get to this soon :slight_smile:

Actually, maybe it will be more helpful if I fix your code. All you have to do is, in the blueprint, select all ( CTRL-A, CTRL-C ) and paste it into a notepad file. The upload that as attachment here.

Hmmm… to many broken variable references ( this method only sends the actual level BP, not all the associated widgets etc ).

Can you make a small project with it in and give me a link?

To make the project, just

  1. Make a new empty first person project
  2. Migrate your level ( map ) to that project ( right-click on your level file and choose migrate )
  3. Zip that project up ( File → Package project → zip up project )

It should only be a few hundred MB.

I’ve sent you a mediafire link by PM, the file ended up being 830Mb!

It’s got some other assets in there that I shouldn’t really share, so please keep confidential.