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"

How do I get the directional vector from left thumb stick?

In my third person character blueprint I'm spawning an actor at it's feet that I then want to move around the screen with the left thumbstick. The plan is to use this as a targeting system that when I release the input it explodes or creates some other object at that location.

I can't seem to figure out how to get the thumbstick input as a directional vector and move the actor based on it. I first tried possessing the actor but that breaks other things like my camera setup. I'd like to keep the third person character facing where I'm aiming with the thumbstick which also breaks if I use possess.

I also tried get left stick X/Y axis but that seems to return the magnitude of the stick input 1 through -1 but I'm not sure how to turn that into a vector.

If anyone has examples of how to do this I'd appreciate it.

Thanks.

alt text

Product Version: UE 4.22
Tags:
spell-targeting.png (160.3 kB)
more ▼

asked Jun 13 '19 at 03:41 AM in Blueprint Scripting

avatar image

Chrisb3d
1 2 3

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

1 answer: sort voted first

sound like you want to use the 'get right vector' node

more ▼

answered Jun 13 '19 at 05:18 AM

avatar image

IndieGameCove
1.4k 11 4 10

avatar image Chrisb3d Jun 14 '19 at 03:29 AM

Hmm, I'm messing around with "get right vector" now but I'm not sure how to apply it. How would you use it in the setup from the image?

avatar image IndieGameCove Jun 14 '19 at 05:32 AM

I can, but I could use some clarification on how you want the movement to work. Is this a sidescroller game? Is the actor being spawned a character that needs to walk on the ground or a projectile that flies through the air? Do you want to be able to control both the actor being spawned and the original third person character at the same time or are you switching between them? how do you want the camera to behave, do you want the camera to follow the new actor?

Maybe there's a game with a similar mechanic you can just link a video to?

avatar image Chrisb3d Jun 15 '19 at 12:32 AM

I made this game in another engine and this is what I'm reproducing in Unreal:

https://youtu.be/h2FmkVZH4Yk?t=22

Local coop. When the player holds a face button down it creates a spell targeting icon. The mage stands there playing a casting animation loop as you drive the icon around. On input release enables the collision volume for on actor over lap or uses that location to then spawn the spell.. Sheep, aoe explode or whatever.

Most of that is easy but I'm having a hard time with getting the actor to move around relative to the camera. Or just move around at all.

This is what I have so far in Unreal for a bit more context:

https://youtu.be/Pl6Nx9YJzno

avatar image IndieGameCove Jun 15 '19 at 03:05 AM

I put an example together you can look at over here. https://youtu.be/q4JUmXbjeDE

avatar image Chrisb3d Jun 15 '19 at 05:24 AM

This is awesome. Thanks for putting that video together.

I ran into two problems:

How to get the position of the projected decal so I know where to spawn the spell object?

and

My camera is contained in a separate actor BP so I can track both characters. I've been trying to figure out how to get the scene component on the camera boom in the character BP to hook up to "Get Forward Vector" and Get Right Vector"

What I've tried so far on both of those hasn't been working.

avatar image IndieGameCove Jun 15 '19 at 06:29 AM

when you fire the spell run a spheretrace from the decal's world location. add or subtract a bit from the z value for the start and end locations.

if you have bridges that enemies could hide under you may need to do a multi spheretrace and look for enemy actors in the array it returns.

is the camera supposed to be at the average position between the two characters? I'm not sure that you would need the camera to be a part of the character. the spring arm could be part of the camera bp, and then you could have a function in the camera to move to the average position which is called whenever you move the characters. are you having trouble getting a reference to the camera in your character bp or vice versa?

If it's a single player game the camera could be the pawn you possess, and control the characters through it by calling functions or sending interface messages. you'd have the camera spawn the characters so you get a reference to them. you could have the decal in the camera if you wanted to.

edit: nevermind the last bit noticed you said local coop earlier

avatar image Chrisb3d Jun 16 '19 at 04:27 AM

How do you get the decals world location? Wouldn't that return the decal components location? If you move it up a slope or down a slope the decal material is projected onto what it hits.. and that's the position I'd need to get but I haven't figured out how.

In my previous projects I think I made a raycast rig and I was able to store the point locations of what it was hitting.

avatar image Chrisb3d Jun 15 '19 at 05:26 PM

Getting variable information from BPs that are not character BPs has been an issue for me from the start. Haven't figured out what to put in the object wildcard when I do "Cast To Weapon" or "Cast To Camera" etc.

I think that's my issue here. I need some way to get the Scene_Camera_Facing from my camera bp into my player character BP so I can get it's forward vector. I tried making it a global object variable and setting it on begin play. But when I tried to pull it up in my character BP it wasn't working.

This is the camera BP setup I'm using to track between the two local coop players and the setup you showed me in your video applied to my player: alt text alt text

Thanks for the help.

character-bp.png (430.1 kB)
avatar image IndieGameCove Jun 16 '19 at 12:56 AM

there are a few ways your characters could get a reference to the camera.

  1. on the begin play of the character you could run 'get all actors of class' since there's only one camera the first element of the array would be the camera. to get the first element of an array you use the 'get' node. Then you save that to a variable.

  2. you could make a variable in the game mode of type bp_camera. on the begin play of your camera you can cast to the game mode and set the camera variable to itself. Then you players can reference the camera through casting to the game mode when they spawn in.

to cast to a gamemode you add a 'get gamemode' node and then use that as the reference when you cast to the specific gamemode.

I haven't tested it yet but I was thinking there's a node called "project vector on to plane" which might work instead of having the scene_camera_facing. Should do the same thing but feel less hacky. there's an example setup over here. https://youtu.be/kGCS4rJYzoM?t=308

avatar image Chrisb3d Jun 16 '19 at 03:14 AM

Ah, nice. I wasn't sure how much I should use "get all actors of class" but I suppose if I just run it one time at the start it can't be that bad. This has opened a bunch of stuff up. I tried the first option and it seems to be working. I'll give the others a shot too.

Thanks!

alt text

castersetup.png (181.2 kB)
(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