Jump to content
  • Advertisement
Sign in to follow this  
Pedro Alves

PlayerController Question

This topic is 528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I using this tutorial to make my game

if want to use the playerController like this toturial

My question i only have to port my input from character class to my playercontroller


Share this post

Link to post
Share on other sites

First this isn't a player controller question, it's sending a message between two classes.

The way I will show you here is a hundred times easier than what most tutorials teach.


First you need to understand the idea: You have two classes/ blueprints that one of them needs to receive a message from the other.

The problem is that the one class has no idea where the other class is or how many there is.


Format wasn't planned, works for a tutorial.

Vid added to show real time effect.


Here is the end scene:

It is a lot of the same class/ blueprint called "Target". There is two lights. We want the first light to to get the color of the first target. We ant the second light to get the color of the target named Bob.



Also to get the color of a material in Unreal it's easier if we set the material color to a parameter and call it "ColorOfMaterial".



Now with this done we go into the Blueprint of the light.

We add a "Get all actors of class" function to our update event.

The actor we are looking for is called "Target" as you can see in the first image.



Now because there can be more than one blueprint in the level of the same type, Unreal will give us a list of objects of the type.

Now because we only want the set the light to the color of the first object, we tell unreal to take the 0 object on the list. Computers count 0-1-2-3...

Once we have the 0 object on the list, we want it's material so we can get the color stored in the material; first we must get the material.



Now that we have the first object in the scene, grabbed it's material we can get the color.

Color is stored as a vector value (Red,Green,Blue,Alpha).

Because all color in the Unreal uses the same color vector we can just plug the color from the material into the color of the light.




OK, We are done.

The color of the light will now be the same as the color of the material from the other blueprint.


Setting the second light is as easy as using a branch/ if to check for the name:

We use a for loop to check each object in the list of "Target".

We get the object name and compare it to the name we want, I named that target "Bob".

We set the color of the second light to the color of "Bob".




Doing it this way is very easy, yet it can be slow in large scenes.

Once you understand all of this you can search how to make a "get" function.

You could also ask here how to make a "get" function, you need to learn this first.


Edited by Scouting Ninja

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!