x

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"

Noob question about Casting/Overlapping Trigger

Hi, i am trying to create a climbing system so i started by creating a blueprint which is based on a trigger box and an arrow which is supposed to be the wall rotation and location. I am using a ''move component to'' to move the capsule to arrow's location and the same for the rotation. I store these variables in the BP_Trigger and use them in MyCharacter. Where everything goes wrong is when i place two BPs of the same class in my level. When overlapping the second placed TriggerBox it rotates and moves my character to 0 0 0 of the world and in some scenarios it keeps the second location but the rotation is still based on the first placed BP in the level? I changed the index number of the ''get'' node when casting to the BP and it chooses the second placed actor as the default one...so i guess it has something to do with this. Any advice is much appreciated!

Product Version: UE 4.14
Tags:
more ▼

asked Feb 12 '17 at 09:35 PM in Using UE4

avatar image

Xanadron
13 17 21 24

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

Ok, i've got some pics alt text alt text alt text

charbp.png (260.7 kB)
triggerbp.png (199.5 kB)
boxtrigger.png (351.3 kB)
more ▼

answered Feb 13 '17 at 04:29 PM

avatar image

Xanadron
13 17 21 24

avatar image MyIvoryTower Feb 13 '17 at 09:23 PM

Oh I see. The main problem here is the array. You should get rid of it because it's not necessary. Let me try to explain what I believe is happening. You're getting all actors of the climb wall bp, but not comparing them with anything, so instead of getting one "right" element and taking the rotation and location of its arrow, you're just getting the location and rotation of every single arrow in your level and moving the capsule to every arrow's position in whatever order the engine added the blueprints to the array. And that's very likely why your capsule always ends up in a kinda random position, depending on how many bps there are in your level.

What I'd do would be to create a variable of type "climb wall bp" -or whatever your bp is called- in your character bp, and call it for example 'climbWall'. Then in your climb wall bp just cast to your character bp on begin overlap and set that variable you just created with a "reference to self". This way you are making sure you're passing the exact instance of the wall your character is overlapping, thus no extra casting will be needed.

Back to your character BP, check if that variable is valid in your custom event and, if so, get the arrow's location and rotation off it and eventually move the capsule, just like you're doing in your current script.

You can also set the climbWall variable to null on end overlap to make sure it's not referenced anymore when you leave the trigger so you can skip the "in climb volume" bool and its validation.

It may sound a bit complex (mainly because I'm not the best teacher in the world, hehe) but it isn't really. If there's anything you can't understand just let me know and I'll upload a couple of pics or try to explain it better. I actually tested this a minute ago and worked like a charm.

Anyway, just out of curiosity, were you using the array when you tried to do everything within the trigger bp? Because I can't see why the results were the same otherwise...

Cheers!

avatar image Xanadron Feb 13 '17 at 10:01 PM

You're a lifesaver. It does indeed work like a charm! Regarding your last question, i wasn't in fact using the array in the first tests. I was desperately searching for an answer to this and i found something regarding the For Each Loop and it's array input which matches with the array output of the Get All Actors Of Class (getting rid of this node after trying your solution) and i thought that was it. Was it really a noob question -haha- ?

Many thanks!

avatar image MyIvoryTower Feb 14 '17 at 09:51 AM

Haha! Cool, glad it worked!

I wouldn't say it was a noob question -maybe not the question an "expert" would ask though, haha- but just a question from someone who got lost and started to try things he isn't very used to work with. It happens to me all the time too, haha. In this case the casting, wasn't the problem, really. The problem was caused by how you were using the array. In fact, the array is still a pretty good solution if done correctly. For example, using the current system you may get unexpected results if the character is overlapping more than one trigger at the same time, as we're passing only the last actor the player overlaps, which may not always be the right one. So if you're planning to place several walls next to each other or in any other way that could cause them to overlap, it'd actually be best to create an array of climb wall bp's in your character bp, and instead of just setting the climbWall variable to self in your trigger, add a reference to self to that array. Then in your custom event use a for each loop and use some maths or tracing to get, for example, the distance between your character and each actor, or even better, check what actor the character is facing and based on that distance/facing direction get the "right" actor, get it's arrow location and rotation, and eventually move the capsule.

Also you must "remove self" from the array in your end overlapp event.

It's a bit more complex, but sort of more precise. But again, this is only useful if there are any chances that your character could overlap several triggers at the same time. Otherwise the current script will work just fine. We don't really need features we aren't going to use, do we? ;)

Cheers!

avatar image Xanadron Feb 14 '17 at 10:05 AM

Actually i was thinking of adding more triggers next to each other, in the case where the character would turn around a corner and that specific corner needs a trigger box, so what you said about the arrays would fit here. Thanks again for the reply!

Good luck!

avatar image MyIvoryTower Feb 14 '17 at 11:23 AM

Yeah, then the array is definitely the way to go imo :) If you need more details about the array thingy just come back and let me know!

Cheers!

(comments are locked)
10|2000 characters needed characters left

Im not sure where your array is coming into play, I think you should only perform your move component to for the current overlapped trigger not via this array. There may be a case where you overlap multiple triggers at the same time but Im not sure if thats what youre talking about it, it doesnt sound like it.

more ▼

answered Feb 13 '17 at 06:08 AM

avatar image

MonsOlympus
963 37 11 37

avatar image Xanadron Feb 13 '17 at 04:31 PM

Yeah i don't think arrays are of any use, just posted some pics in another reply, hope it helps. The problem is that the stored variables do not change depending in which BoxTrigger i am.

avatar image MonsOlympus Feb 13 '17 at 06:28 PM

I can see what youre trying to do, I think the best option is to not have a separate function like that and to do it all in the overlap for now so you can lay it all out and see how it fits together. From there it should be okay to split it up is thats what you require from the system, I think this level of abstraction is confusing you slightly.

avatar image Xanadron Feb 13 '17 at 06:49 PM

I also tried doing the work in the Trigger BP directly but unfortunately it does the same thing. I used a print string to print the world location of the Arrow but it never changes when exiting the Trigger nor by setting it to zero when ending the overlapping.

(comments are locked)
10|2000 characters needed characters left

Yeah, what MonOlympus said. A screenshot of your BP may also help us find out what's going on in there.

more ▼

answered Feb 13 '17 at 08:18 AM

avatar image

MyIvoryTower
88 4 5 7

(comments are locked)
10|2000 characters needed characters left
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