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"

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.

Product Version: UE 4.20
more ▼

asked Feb 26 '19 at 05:52 PM in Blueprint Scripting

avatar image

3 1 3

avatar image ThompsonN13 Feb 26 '19 at 11:04 PM

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.

avatar image Nebula Games Inc Feb 27 '19 at 01:22 AM

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

avatar image MajexEdge Feb 27 '19 at 01:21 AM

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

script.png (248.0 kB)
avatar image ThompsonN13 Feb 27 '19 at 01:54 AM

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.

avatar image MajexEdge Feb 27 '19 at 04:37 AM

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.

avatar image Nebula Games Inc Feb 27 '19 at 06:43 AM

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.


avatar image MajexEdge Mar 03 '19 at 09:48 AM

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://www.youtube.com/watch?v=TQjX2jldBEc 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.

capture.png (367.2 kB)
capture0.png (385.8 kB)
avatar image ThompsonN13 Mar 03 '19 at 03:26 PM

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.

alt text

capture.png (100.0 kB)
avatar image Nebula Games Inc Mar 03 '19 at 03:52 PM

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?

avatar image MajexEdge Mar 03 '19 at 08:10 PM

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)

capcontroller.png (393.3 kB)
caplevel.png (357.9 kB)
caperror.png (425.3 kB)
avatar image Nebula Games Inc Mar 03 '19 at 08:38 PM

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?

avatar image MajexEdge Mar 03 '19 at 09:48 PM

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.

avatar image ThompsonN13 Mar 03 '19 at 09:56 PM

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.

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

1 answer: sort voted first

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....

alt text

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.

alt text

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.

level-bp.jpg (109.6 kB)
more ▼

answered Mar 03 '19 at 09:05 PM

avatar image

Nebula Games Inc
5.4k 28 9 15

avatar image MajexEdge Mar 04 '19 at 12:02 AM

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"

avatar image Nebula Games Inc Mar 04 '19 at 12:11 AM

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.

avatar image MajexEdge Mar 04 '19 at 02:03 AM

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.).

cap.png (974.3 kB)
cap0.png (1.1 MB)
cap1.png (950.8 kB)
avatar image ThompsonN13 Mar 05 '19 at 02:42 PM

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.

avatar image MajexEdge Mar 08 '19 at 07:46 AM

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.

avatar image ThompsonN13 Mar 08 '19 at 02:29 PM

i have no idea what your trying to say here.

set the player controller? you should have one that you use by default based on the game mode. all you need is a reference to the controller which you can get using the get player controller node.

your second sentence is incomprehensible nonsense. so i dont know what to make of that.

avatar image MajexEdge Mar 09 '19 at 07:58 AM

Not exactly incomprehensible if you read it to understand instead of just skimming to see what is said. The PlayerController has been set already each and every time in the Game Mode. If that's what you mean by setting then I have no idea what is causing the different results and I'll have to stay with "Player Start".

avatar image Nebula Games Inc Mar 09 '19 at 01:38 PM

No, both I and ThompsonN13 were always trying to figure out how you "set" the variable "New Var 1" from your screen shots. That looks love a controller object reference you "use" but never actually "set" which would cause you issues.

avatar image MajexEdge Mar 10 '19 at 07:28 PM

Then the same question returns "how do you set the 'PlayerController' then?". Your saying to set it and Thompson references the game mode and "GetPlayerController" node which are two separate things.

The "NewVar1" variable was made by making a variable, changing the variable type by searching the blueprint by name and setting it as an "Object Reference". If you mean selecting the variable and putting both a "Get" and "Set" node of which the "Get" goes into the "Set" node while connected to "EventBeginPlay" (Just like in the pic) then I have already tried that.

What I don't understand is why I need to set the "PlayerController" when its already referenced by the "GameMode.

cap.png (285.9 kB)
avatar image Nebula Games Inc Mar 10 '19 at 08:12 PM

You're not understanding how a "reference" works and/or the purpose of casting. You said you looked through my tutorials and epics and they were "useless" if you're starting from scratch. I honestly don't know what else I can tell you at this point. When you create a variable the way you did its just an empty container that can hold data of the type you specify (controller object in your case). It doesn't "fill" the container with data hence your previous issue with "accessed none" ie. No data. You need to use a node like get player controller and plug the output INTO the "new var 1" as a set node so that your controller object variable actually references something specific. ThompsonN13 was saying that's how to do it. His comment about the game mode was saying that you should not need to do any of that because a newly created pawn should be default possessed by the correct controller specified by game mode.

avatar image Nebula Games Inc Mar 11 '19 at 02:19 AM

Here is a screen shot of what we have all be trying to explain to you. Maybe this will help clear things up.

alt text

alt text

alt text

avatar image MajexEdge Mar 11 '19 at 05:50 AM

Took out the pawn reference in level and used "SpawnActorfromClass" to fill pawn that's to be possessed and works without a single problem. (Tried Pawn reference as well, no problems)

The only reason I didn't understand what you meant was because the Game Mode sets what is the pawn and controller, hence why I believed that there was no need to set or possess. It works perfectly, but as far as I'm understanding it, your telling the level blueprint to cast to the "PlayerController" to set itself as the player's controller within itself which sounds redundant. Thanks again for the help. (Blaming that redundancy on Epic)

(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