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"

Forward/Back input movement instead of Axis

I want to try and create an old school First Person dungeon crawler similar to old school games. An example is https://youtu.be/EV28-iHbISU?t=10m Except replace clicking on screen prompts with WASD.

If the video is not obvious or you cannot watch the video the movement system I want to implement is: - Pressing W or S will translate you forward/back X amount of units. - Pressing A or D will rotate you left/right 90 degrees

Right now I have my rotation working alt text

(I am aware that a lot of stuff can be connected so it looks cleaner, just haven't done it yet. However if you know a more performance efficient way to do it I should know, that'd be helpful.)

However my forward/back blueprint is not working alt text

The issue that comes up is weird results coming from actually pressing the input. The timeline goes from 0 to 40 and the start location is at 100.

If I press W 4 times it'll go

  1. X = 100 (intended: 100)

  2. X = 240 (140)

  3. X = 380 (180)

  4. X = 520 (220)

The other issue that will show up later is the way my blueprint is set up now, if I rotate my camera 180 degrees I will essentially move backwards if I press W. Is there a better solution than making a branch with 4 variables for each rotation (90, 180, 270, 0) and change X/Y depending on which variable is checked?

Product Version: UE 4.10
Tags:
rotation.png (307.6 kB)
relative01.png (156.8 kB)
more ▼

asked Apr 08 '16 at 03:19 AM in Blueprint Scripting

avatar image

HeartTrauma
5 1 3 5

avatar image keyle Apr 08 '16 at 03:59 AM

I think the W going backwards is because you use relative rotation. So in terms of world rotation you haven't turned, hence pressing forward will go backwards.

Look at using Set World Location, or Add World Offset instead.

avatar image HeartTrauma Apr 08 '16 at 01:34 PM

I manged to solve my ridiculously increasing speed issue (I replaced get world location with get relative transform, breaking the transform to get location and use that value.

Now I just have the issue with it not moving the direction I want when I press W. I've tried world location and world offset which both didn't work, however I adopted world rotation over relative. Right now my current solution is very silly but works. (I currently have a branch checking which direction I'm facing and I do different operations based on it)

if my worldRotation is -1 to 1 it transforms X positively by 280.

if my worldRotation is 89 to 91 or -269 to -271 it transforms Y positively by 280.

if my worldRotation is 179 to 181 or -179 to -181 it transforms X negatively by 280.

if my worldRotation is -89 to -91 it transforms Y negatively by 280.

Doing something like would, would I expect any performance problems?

avatar image keyle Apr 08 '16 at 10:53 PM

Assuming this only happens on key presses, I don't think it would cause any performance drama.

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

2 answers: sort voted first

Are you using a timeline or matinee for this? The blueprint looks odd to me:

I don't recommend using "SetRelativeLocation" as this sets a local position I believe. You'll want to inerpolate between your new location and your old location to get a smooth transition but if you don't care about that, setting world location is fine. The other issue you're going to have is setting your location relative to your camera orientation.

Should look more like this i think: (wasn't able to test this one)

alt text

Basically:

  • Get actor rotaion

  • From rotation get forward vector

  • Multiply forward vector by distance

  • If moving backwards, multiply distance by -1 first

  • Add vector result to current location (captured after "set location" of course)

This does not solve rotation, but that is handled by:

  • Receive input

  • Get actor rotation

  • Add 90 or -90 rotation on axis to character rotation

  • Set character rotation

Hope that helps! Good luck!

more ▼

answered Apr 10 '16 at 12:31 AM

avatar image

dsmith
186 9 3 10

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

GetActorForwardVector and GetActorRightVector

http://i.imgur.com/hLmscXR.png

E: I see you are moving a FirstPersonCamera around manually. I was doing similar with a 3rd Person Camera and found it awkward. It is much easier to use a Pawn(or Character) class to deal with movement in the world. You can then attach a camera to that class and set the relative location (eye height for example). This is how the editor camera works for example.

more ▼

answered Apr 10 '16 at 12:08 AM

avatar image

Nodrak
26 1 4 6

(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