Beginner: Moving Objects

Sorry for the delayed response!

Let’s say your cube BP is called BP_MyCube and you have your character BP_Character*(obviously it’s named something else in the FP template)*. If the cube exists in the world and you want to move it via using your keyboard, you first have to get a reference to it. We use this reference to manipulate that object, whether it is to move it, rotate it or call some function on that object. So how do we do that?

Method 1: Spawn the BP_MyCube via your BP_Character using the Spawn Actor from Class function*(for example from BeginPlay)*.

When you spawn an actor, you immediately get a reference to that object*(Return Value)*. Now you can drag this return value somewhere and you’ll get the option to promote it to a variable, go ahead and do so - then we can use this variable to access the object at will. For the sake of this example, let’s say you named the variable MyCube_Ref.

Now inside BP_Character you could repeat the code you provided above, but instead this time you do it like this;
N -> MyCube_Ref -> Add Relative Location.

I’m sure you know how to drag the variables to set/get them.

Method 2: If the cube is part of the map, you can get a reference to it via Get All Actors of Class*(change filter to BP_MyCube)*.

This function will return an array of objects which you can loop through. If you know there will be only one cube in the world, you can use the get node with an index of 0 instead of looping through the array. Once you’ve got the reference to the cube, you repeat the same as above.

Again do note here that the input is handled via BP_Character since it will register input, BP_MyCube will not as it’s just an actor.

Hopefully this was a bit more explanatory :slight_smile:

This could also be achieved in UE4 simply by using the GetPlayerController node, player 1 will have the index 0 and player 2 will have index 1 and so on.

Unfortunately multiplayer in UE4 is a bit convoluted*(but powerful)* when compared to other engines and not very well documented yet. All they really tell us is how to click a checkbox to enable replicating and using the authority node. They do a really, really bad job at explaining and showing how to set up a MP testing environment that accurately produce the same results you would get in a packaged game*(I have yet to figure this out, closest I’ve got is to just package the game and run it on my laptop, have not yet found an environment that works in UE4 Editor)*.