Move an object using c++

Depending on how you spawned them you can either iterate through the array of them. If you somehow dont have the references you can use the engine function A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine ForumsObject%26_Actor_Iterators,_Optional_Class_Scope_For_Faster_Search

That being said, there are some basic C++ concepts you might be misunderstanding. An instance is an object created from a class definition. So you dont have a concept that matches “same objects of the same instance”. Further, if it is the same instance then it is the same object and that will always have the same position. Further, if you can spawn it, then it is not an object, but an actor. I assume you meant “two separate instances of the same class”, in which case you just have to loop over the array and compare the actors location by this formula:

(AActor.GetWorldPosition() - BActor.GetWorldPosition()).LengthSquared() < 0.0001

The boolean result of the above formula will tell you what two actors are in the same location, if any.

HTH

It is a function that actors have. It returns the vector in world space that represents its position.

hi! i am completely new to c++ coding on ureal, but i have experience coding on c++ making applications
I have created a class and i want to move an specific object(instance of the same class) and i want to ceck if two objects are on the same position(same objects of the same instance) so they exchange positions, i hope you could help me with that

thanks and you’re right i just made a mistake while i was writing i meant “objects of the same class” just another question… what does it mean with the “getWorld()” function???