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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

When teleporting character, character often teleports to the wrong location

Hello there, I have a problem with my teleportation script. Here it is: alt text So, when I click 'F', I normally teleport to where I am looking. Occasionally though, I teleport to the wrong location, but it is always the same location, not just some random location. I have tried using both a 'teleport' node and a 'set actor location' node. Both yield the same result. The variables and flip flop are just for the animations I made. I have set it up so that you click 'F' once to aim, and then click it again to teleport.

Link to a video of the error occurring: Click here

Help is much appreciated.

Product Version: UE 4.12
Tags:
screenshot (65).png (268.3 kB)
more ▼

asked Dec 31 '16 at 05:15 AM in Blueprint Scripting

avatar image

YaBoiGazza
5 4 5 6

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

4 answers: sort voted first

I figured out what was going wrong. When I was doing the trace, I multiplied the forward vector by around 2000 to get a line that long. When I aimed at a location further than that away, the line trace could not go that far, and thus never hit anything. When I teleported to the hit location, it teleported me to 0,0 in terms of x and y, as there was no hit. Changing the multiplication float to a large number such as 50000 solved the issue.

more ▼

answered Jan 04 '17 at 06:43 AM

avatar image

YaBoiGazza
5 4 5 6

avatar image JaroMast Jan 04 '17 at 11:32 AM

That is exactly what I wrote as answer 4 days before you figured it out :)

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

Have you checked to see if the place it teleports you to is vector 0, 0, 0? I had this problem when I implemented my blink spell. In my case I fixed it by doing a check on the location pin from the Break Hit Result. If it is equal to 0, 0, 0, then I do not let the player teleport.

more ▼

answered Dec 31 '16 at 06:12 AM

avatar image

Dartanlla
2.6k 62 26 281

avatar image YaBoiGazza Dec 31 '16 at 07:31 AM

No, I don't believe it is. Even if it was, then your solution would make it so it would not teleport if the error occurred, which would be just as annoying. Any other ideas?

avatar image Dartanlla Dec 31 '16 at 04:06 PM

In my case it was okay to stop the player from teleporting since I am replicating the blink spell from WoW which also sometimes did not teleport in rough terrain. Some things you might try are replacing the line trace with a capsule trace, enabling trace complex, and adding code on the hit actor result that verifies the location to teleport is valid. I watched the video and was not able to see what you mean when you say it always teleports to the same place.

avatar image YaBoiGazza Jan 04 '17 at 06:35 AM

Turns out the location the character is teleporting to is 0 on the X and Y axis, but not on the Z axis. Either way, I'll see if using the capsule trace works.

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

I just dont understand why you are taking WorldRotation of your camera and after that a forward vector. Just forward vector isn't enought?

But about this error, LineTraceByChannel returns bool value, it shows if there was collision or not. It can simply happend that you dont have a point in 2000 units forward so it will teleport you to wrong direction.

My suggestion: check the return value from LineTrace, if there is a collision teleport to location from HitResult, if not teleport to location pinned to End slot in LineTraceByChannel node.

more ▼

answered Dec 31 '16 at 09:30 AM

avatar image

JaroMast
380 31 21 40

avatar image YaBoiGazza Dec 31 '16 at 03:16 PM

The rotation of the camera means that a line is traced from where the camera is looking, and thus where the character is looking.

(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