I’m using Unreal Engine5 default first person. I’m trying to hold a wheelchair and push it around. So far I have added a collider to the static mesh (the wheelchair). And added a collision box that at the back of the wheelchair so it gets detected ONLY when the player is standing there (ready to push).
Here is the blueprint of the wheelchair, and it is working, it gets triggered when player is in the right place to push the wheelchair.
But I don’t know how to push it around! I want the player to hold the chair once he is in the right place and when he presses a certain key. Then he is able to push it around and then when pressing same key he releases the chair. Is there a simple way of doing that? please help.
There are Blueprint nodes for “Attach Actor to Actor” and “Detach From Actor”. Make sure the Mobility of your wheelchair is set to Movable first. That would be your first proof of concept and then you’d have to get into physics, sockets, animation blueprints, etc.
If you’re brand new to UE there will be a few more concepts to learn about communication between different actors in the world. This tutorial will get you started with the bare minimum and there are other ways to make it robust. Your box could detect overlap and then attach itself to the overlapping character. Or most likely your character will check for overlapping objects and then attach them.
You can also look at the VR Template project which has a whole system for Grabbable Objects.
+1 for using the ‘attach’ system. The base of the First Person Character is a capsule that will rotate to the direction you’re facing. (As opposed to attaching something to your camera which would rotate freely with your camera)
For input - I think creating a boolean that gets set to true/false as you enter/exit the overlap box would be a straightforward way to gate input. (On “Use” input - check if boolean is true or false and branch accordingly)
So I tried this in the character blueprint, I’m trying to get the static mesh (the wheelchair) and the variable of that static mesh blueprint (bool :canPush), but it is giving me error on both nodes.
Actor to Actor didn’t work for me, So I aded component to component node, but I couldn’t get the variable from the other blueprint (the wheelchair’s), please see the reply I added a screenshot and please help me if you know what’s causing the errors.
Be sure to properly get your object (wheelchair) as this BP will attach it no matter where in the world it is.
However, you might see that the object is blurry when you move around quickly. I assume that is because the camera of the parent object is updated before the position of the child object making it always one frame behind.
Think about his though… Is the wheelchair that different from a weapon pickup? When you pick it up it attaches to the character. It can even change the character’s movement characteristics. If you also see the similarities you can check how the weapon is made in the first person character example.
Alternatively you can treat the wheelchair as a vehicle. This can totally change how the player behaves when pushing it. When you press the button instead of attaching it you directly possess a wheelchair character with different capabilities.
Anyway, hope this is not too confusing and at least some of it helps.
So this has to go in the player blueprint not in the wheelchair?
Also using your method I can’t activate pushing when a key is pressed.
and can you please tell me how to get the first red method? I don’t have shooting !
Yes this is in the character blueprint as it is the place that receives the input. You can probably move some of the logic in the wheelchair but you will have to start from the character or the controller as they handle your keyboard.
The first red node is just something I had handy from the first person example. It is equivalent to your G key.
Here:
I tried to move all these nodes to Wheelchair blueprint, but it didn’t work. may I ask you what is held actor in your blueprint? is it from wheelchair class? or a variable you made in the player blueprint?
As I said - moving them in wheelchair will not work as the wheelchair will not receive the "G event.
That logic should be in your controlled pawn. Held Actor in my case is a Wheelchair actor variable and it is set in the red comment.
For Held Actor, you created a variable inside the player blueprint and set its type to wheelchair actor Am I right? Anyway thank you so much now it works but very weirdly but at least it is working I can call it a start. But when holding down the key, the chair goes far away and moves from far way. Also it gets lifted. it is in the air not on the ground. But will try to figure it out. Thanks again.
This will get the wheelchair from anywhere. You will have to modify this with your desired behavior - maybe you have to be near the wheelchair and looking at it.
Use this offset to attach it properly: Try setting Z to -100. You can also reduce the X if the object is too far out.
I would suggest using a physics constraint component to tether the wheelchair too the player on interact. Then break the constraint on a second interact.
It would be the wheelchair in your case. it’s an exmaple i took from another answer i gave which is why it says rope instead, you also don’t really need to specify the bone name either.