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"

Teleport by set amount from forward vector C++


I'm working on a 3D project within Unreal but am running into issues with a blink ability/teleport ability I am coding. For some reason my character does teleport, but only in one direction, from what I can see this is the X axis. Most of the examples I can find on this topic are using blueprint, in which I am struggling to convert into working C++. I've also included the log, which to me returns what I would expect. The project is built on top of the Third Person platformer template within Unreal. Any help would be greatly appreciated, I've attached a code snippet below of the blink method.alt text

alt text

Product Version: UE 4.15
teleport.png (11.9 kB)
log.png (7.6 kB)
more ▼

asked Jul 05 '17 at 01:27 PM in C++ Programming

avatar image

3 1 2 3

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

1 answer: sort voted first

You could be colliding with something. Check the return of SetActorLocation and maybe pass in the OutSweepHitResult variable for more info.

more ▼

answered Jul 06 '17 at 02:31 AM

avatar image

58 1 9

avatar image Magmafire Jul 07 '17 at 07:44 PM

I think you may be onto something there. I've added a second log which is the FHitResult and the location which it returns is not the same one that I expected.

 LogTemp:Warning: Previous Location: X=0.423 Y=-0.906 Z=0.000, NewLocation: X=21.153 Y=-45.305 Z=0.000
 LogTemp:Warning: HitResult: bBlockingHit:True bStartPenetrating:False Time:0.006880 Location:X=-309.636 Y=88.372 Z=207.080 ImpactPoint:X=-309.635 Y=88.372 Z=130.280 Normal:X=-0.000 Y=0.000 Z=1.000 ImpactNormal:X=-0.000 Y=0.000 Z=1.000 TraceStart:X=-313.074 Y=89.769 Z=209.229 TraceEnd:X=21.576 Y=-46.211 Z=0.000 PenetrationDepth:0.000000 Item:-1 PhysMaterial:N
 one Actor:Floor Component:StaticMeshComponent0 BoneName:None FaceIndex:-1

I've also made a slight alteration to the SetActorLocation code as I believe this before would of returned an incorrect value.

 bool Success = SetActorLocation(Direction + NewLocation, true, &OutSweepResult);

I also tried rotating the player start by 180 degrees. To try and determine if the Forward Vector I was getting was incorrect, but again the character only teleported in one direction.

avatar image Magmafire Jul 07 '17 at 07:51 PM

Just after I replied I had another look through the log message and I found the issue. It was the values I was passing into the SetActorLocation

Previously I was passing in Direction, which was the Vector that represented the way the player was facing:

bool Success = SetActorLocation(Direction + NewLocation, true, &OutSweepResult);

What I actually wanted was to pass in the current GetActorLocation and add the NewLocation to that.

bool Success = SetActorLocation(GetActorLocation() + NewLocation, true, &OutSweepResult);

Thanks for pointing me in the right direction!

(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