I don’t get it! I read the documentation, I read other threads but I couldn’t find a solution to my problem.
Perhaps I have overlooked something simple.
I just want to hand over the AxisValue/MouseFloatValue from the MyCharacter-Blueprint to the DoorAdvance-Blueprint but I don’t know what
to do with the ObjectInput…
For the ‘Object’ you will need to give an actor reference the ‘DoorAdvanced’ you wish to cast to. This actor will need to be the same class as the object you are trying to cast to or the cast will fail.
You will need a way to reference the ‘DoorAdvanced’ actor. For example from a collision box on the player and saving the reference when he collides with the door (or within a certain range), then once you have that reference it will should ‘hand over’ the values
The object input should be the actual actor of the DoorAdvanced. EG. the 1 placed in the level that you want to do something to.
The easiest way to do this is do a “find all actors of class” and then get actor 0 from it. That’s definitely not the recommended way to do it for a proper game but thats the fastest way for you to get it running.
Using Overlap Events of Collision Components that provide you with an Output called “OtherActor”
– A Collision Component (or Mesh etc) can have Functions called “OnBeginOverlap” and “OnEndOverlap” or something like that
– These Functions have the above mentioned “OtherActor” Output that provides you with a reference to the overlapped Actor.
In this case, your Door and your Player should overlap and inside of the Player you get the “OnBeginOverlap” function of the Capsule Collision
that you character already has. Then you save the Variable and set a bool that you name yourself (e.g. bIsOverlapping) to true.
In the “OnEndOverlap” you set the bool back to false and clear the Reference variable from before.
Then in your “InputAxisTurn” thing, you check with a “Branch” if the bool is true and then use the reference you saved in the “OnBeginOverlap”
and cast that to your door.
Even better would be casting the OtherActor directly and saving the reference in a Variable of your Doors Blueprint Type. Then you don’t need
to cast in the “InputAxisTurn”, since casting so often isn’t good either (Axis events tick…)
A similar way would be using a “SingleLineTraceByChannel/Objects”. You can perform that on E press in the camera direction (A LOT of tutorials
about this can be found) and use the “HitResult”, which you then break, to get the “HitActor” which you cast to your Door Blueprint then.
The cast will of course fail if it’s not a door you hit.