How to get the reference for a specific object?

Hi -

I am new to UE4 and I’m trying to understand how to organize my code. I come from Unity and the way it works there, is that you add scripts to the objects.

I went through all programming tutorials in the website, but there was no tutorial or example that shows how to reference and add code to specific objects. I also tried to find a similar question online, but couldn’t find it.

For example, if I have a sphere and I want to add some code to it, like adding some force to it, or interact using the keyboard, how do I start that? Is it just using Blueprints or can you do it using just code? And if I need to reference another object in the level inside that code, how do I do that?

If anyone can point me in the right direction to understand I would really appreciate.

Thanks!

Blueprint and C++ class is the same thing. Class is like a master copy which from you create object, if you add code to class, every object made out of this class will have that code. It’s a system which most objective languages works, you can’t add code on the fly.

As for how to get reference of a actor, there many ways to do that for example ()->SpawnActor() will spawn object of some class and return instance of object which you can keep in variable and call functions to it, many events gives arguments of related objects, if you can get refrence to object you want you can get any object from world by TActorIterator.

Cool, thanks for the explanation. I found this tutorial which is helping me understand the whole thing.