Blueprint Scripting simple vector movement

Hi, I’m trying to make a simple pawn with inputs to move along the Z and Y axis. Currently I have a pawn without scripting, Auto possess enabled and Player 0 set for taking input. The playercontroller has the input commands and has flows to SetActorLocation with a node connecting to its new location as follows ( GetActorLocation > (vector + vector) Z +100 > SetActorLocation) The action for the input fires, but nothing happens. I’ve tried other suggestions involving Axis movement and blueprinting in the pawn. However the results are random as sometimes it will work when reworking from scratch again and other times it will simply not fire at all.

so whats your question? i assume it why is it not working and how do you fix it right.

first what kind of input are you using? is it action or axis events or basic key press? it would help to see the actual script also.

my guess to your issue is that your probably not getting the controlled pawn in your script, it would be the target for the get and set actor nodes. you need to specify the controlled pawn since your script is in the controller and not in the pawn itself.

I tinkered some more and decided to use code from another project I had and it works consistently (Pic is code being used now). However I would like your input if there is a better way to do it because I have a feeling it will cause trouble later on. Thanks for the reply and help

Yep screen shots and probably ThompsonN13 is correct, sounds like the “Set Actor” node isn’t hooked up to the actor.

theres a few things of concern here.

first your method of getting the actor isnt great. im assuming that the actor your looking to move is the one the controller is in possession of right? if thats the case use the “get controlled pawn” node instead. it will be easier and more reliable.

the other thing is your method of movement. do you really want to have such jumpy movement? the way you have it now the pawn will basically teleport to the new location instantly. would you rather have a move over time? then again i know nothing of your game so thats your call.

Thanks, for some reason before when I tried using Get controlled Pawn it didn’t work. I replaced it and works just as fine, but of course without the array. What I’m wondering is what could prevent that setup from working. Also the teleport is fine, just trying to understand the engine from scratch instead of the tutorials.

Sometimes blueprint nodes are just broken. Delete and replace usually fixes that. Maybe your node broke internally somehow. Also I know you said you are trying to learn the engine from ‘scratch’ and not tutorials but tutorials are not all bad. A lot just don’t explain things and teach a specific mechanic as opposed to a generalizable concept. If you want to learn concepts and basics of blueprints this series I made may be helpful to you.

Funny thing is now none of it works after trying to replicate the success. The code is the same and I’ve looked through some of your tutorials and several other things (I have gone through Epic’s tutorials before and quite frankly they’re useless if your trying to start from scratch).

https://docs.unrealengine.com/en-US/Gameplay/Framework/Controller https://docs.unrealengine.com/en-us/Gameplay/Framework/Controller/PlayerController https://docs.unrealengine.com/en-us/Gameplay/HowTo/PossessPawns

Possess, Functions, Cast to, etc. do not work. The tutorials by Epic have been useless and only the youtube link has provided some help, even when it didn’t relate entirely to my problem.
Either I’m getting the “access none” described in the video or nothing happens without error despite the same exact code setup put up previously here (with exception to the array being replaced by “GetControlledPawn”). So to break the process down…
The first pic is the level blueprint that spawns the pawn and fixates the view to a camera in the level itself.
The second pic is just the input action from the controller that’s supposed to simply move the pawn from one point to another with each press.
To be honest I’m losing my patience in something this simple and yet with very little answers, so by all means if i’m missing something or simply done it incorrectly let me know.

ThompsonN13 is correct. Also what do you mean casting, functions, possess don’t work? You have screen shots of how you are using these nodes and the error you get?

theres two issues with the pictures you posted.

first if your planning to use the pawn that your spawning you need to posses it. if you dont posses the pawn it wont move and get controlled pawn wont work.

second in your controller you are setting the location but you dont specify the correct actor. you see where it says target self on the set actor location node, that mean that your targeting the controller. what you need to do is connect a reference to the actor your trying to move, so the controlled pawn in this case.

Its as I said, it doesn’t work. The new pics is the previous setup I had before I just exited without saving. It doesn’t work and errors come up saying “Access None” from which as I understand, the variable being called has no variable to call from. Which doesn’t make sense as its calling a blueprint that’s already defined in the Game Mode blueprint.
The other errors were from me forgetting that I set the default pawn in the game mode as “None”.
So as far as I understand, the controller is not being called to control the pawn. However I found that if I activate the input multiple times a shadow rises over the spawned pawn which makes me assume that another pawn is being spawned by the Game Mode behind or at the camera location. From what I know about Game Mode, its supposed to define the pawns, controllers, etc. not spawn them correct? (Game Mode blueprint has no nodes within it)

Where did you set “New Var 1” that is a controller type reference? Also, why bother “spawning” a player in. Have you tried using the “player start” component and going from there?

I just reproduced this setup and it works fine. Here is what you need to do.

  1. Create a Pawn class
  2. Create a Game Mode
  3. Create a Player Controller

In the pawn BP, select “Your_Pawn_Name(Self)” from the components tab in the viewport. On the right hand side, look for the sub category tab “Pawn”. In this category you should see, “Auto Possess Player”. Spare yourself the trouble of assigning a controller and select “Player 0”. Open up your game mode. Look at the top panel and find “Class Defaults”. Select this tab. On the right hand side you should see a list of options with drop down menus. Find “Player Controller Class” select the player controller BP you created. Find “Default Pawn Class”, select the pawn you created. In your controller place the following script…

Finally, open up your level. On the right hand side you should see a tab that says “World Settings”. Click this. The second category is “Game Mode Override”, select your game mode from the drop down menu. You should see if you expand the “Selected Game Mode” arrow below it your default settings you set up with your player controller and pawn. And last but not least, open up your level BP and place this script in there.

Now when you hit play and press the “T” key or whatever key you want it to be, your pawn will move up 100 units on the Z axis.

I just tested “player start” out and everything is working without error. The problem is that “player start” is hardly mentioned and most other forums I looked up usually just used “spawn actor”. I don’t even understand why the previous setup wouldn’t work with the given nodes and variables. My only remaining question is where to find the world location for a selected actor? After an update I haven’t seen it on my world settings panel.

you wont find the location of a actor in the world settings, a actor location will be in the details panel. world settings only deals with the world itself not the objects contained within the level.

Can you record a video? I am really at a loss here why this isn’t working for you. Also just saw your other comment about “player start”…if it works with player start seems your issue is how to possess the spawned actor. I also never saw how you set “New Var 1” for your original set up. Didn’t look like you used a set nose after spawning a player controller.

I appreciate the help, but I followed your instructions, and repeatedly checked to see if I missed anything and it still doesn’t work. The pawn is right underneath the camera’s view and when I push the action key enough times a shadow appears from below. Its the same result and its the most logical way to build the blueprints to do what I want, but I don’t know If its the game engine itself, the version being used or something else. Regardless, thank you for the help especially with “player start”

I tried to upload an attachment that was a video, but the site won’t accept it. Its essentially the three pics where the first one was the editor itself, the second while playing at the start and the third is when the shadow appears over the cube after activating the input a few times. As for the “New Var 1”, its just a variable that calls the PlayerController blueprint. As for setting it I don’t know where the set node would be put since the variable is calling a blueprint and not a variable attached to a blueprint (like a float, vector, etc.).

so what your saying then is that your not setting the variable. if thats the case how would you expect it to work? i would get rid of the variable there and for now just use the get player controller node that you already have.

oh and as for the video you cant attach them directly here, you would need to upload it to something like youtube first then post a link.

Then how do you set the PlayerController then? Because you don’t set the Game Mode, Pawn, etc. since your usually calling variables from the blueprints.