This is inside a blueprint class called Portal 1, I have a similar class called portal 2, and both of them are placed in my level. However, when I try to retrieve the world location with the get world location node it gives me the error “accessed none trying to read the property”.
What I think this means is that the root component is none, which means the return value of the actor class is none. This makes no sense as when I press play “Event BeginPlay” should run and get the actor of the class Portal 2. I obtained the variable “Port 2” by doing the following:
The first pic looks dodgy. How do you actually access the data? What fetches it and, most importantly, when are we doing this?
And no, the root component wouldn’t matter. You can do this instead:
The root is always there, if you do not put a specific component as root, you get the default one. And root location is always the same as actor location.
Also there are easier and more natural ways to connect two actors that are placed in the level. What you’re doing is fine for experimenting but will get out of hand with more portals.
I’ll gladly explain. The portals in the end are going to be spawned from the player. In one instant there can only be two portals in the world, portal 1 and portal 2. These are separated into different blueprints for my convenience and should always connect. There will never be more than one portal 1 and more than one portal 2. Also they should be movable.
GetActorOfClass can’t return None if there’s an actor in the level of that class. Are you sure that you’re calling it when an actor of that class exists?
The CA_Portal is a Child Actor Component that will automatically create an actor.
Instead of laboriously making and destroying portals, you can show / hide them instead. The portals live in the world space (Absolute Rotation and Location) so they can be placed anywhere in the world and will not follow the player.
the pure function traces in the direction where the actor is pointing:
There are better ways of doing this but it can be refactored later. Also, it would be much better if the portals were of the same class or, at least, inherited from the same class.
So if Portal 1 wanted to talk to Portal 2 via a direct reference:
This can be optimised, of course, but depends on what we need to do next. Perhaps there should be no logic in the portals themselves, the player could manage them since they know about both from the get-go…
Sorry for the late reply, I’m implementing what you said. But when I move my character or rotate my view the placed portals move. I do not know if it changes things but I’m using UE5. The only difference I see in our code is the default structure of the first-person character: