Download

Wheeled vehicle with other animations

Hello,

I am trying to make a forklift that can obviously drive around and lift the fork (in three segments).
I have successfully created my vehicle blueprint and got the driving part to work.
Now when I add the animations for the fork to the animation blueprint, it works! so that’s great or so i thought.
When I add physics to the animated parts it fails and I need this since its the only way to get collision on the fork is through physics since its a skeletal mesh.
I wasted the entire day yesterday looking for the solution and I sort of found one, the problem is the bone settings.
The bones that are affected by the animations should be set to kinematic, the issue there is that the vehicle part fails and I cant move the forklift anymore.

There must be a solution to all this that does not require stripping my skeletal mesh into pieces and using my own animations??

Thanks in advance =)

Nobody with a solution to this problem? There have to be more people struggeling with this?

I didn’t really want to revive an older thread, but since there hasn’t been a solution posted, I figured I would revive it.
I started working on a forklift type of object yesterday, and running into the exact same issue. Without any physics on the forks, I can move the bone and drive around just fine, but that is pointless as I wouldn’t be able to pick anything up with the forks.
So then I added physics to the forks, and made them kinematic so they can animate. This now allows my forklift to carry something, but does not allow the forklift to move.
I have been scratching my head as to what to do. I looked online for a solution but cannot find one, at least not yet. I did notice that you have another thread where you have managed to get it working.
I was just wondering how you solved the problem?

Or if someone else has a solution, that would be great :slight_smile:

What would be if you add a socket to the (car)body and ex/import the forklifting part seperate?
Add the lifterpart to the socket, move the part, where you need it, and for the physics use under collision “overlap only pawn”.
Greetings

Hi Luftbauch.

I was trying to avoid doing it that way, but would have done so if I had to.

I worked out that it was to do with the constraints.

While the “forks” bone was constrained to the root bone, the forks could move, but not the vehicle.

So for now, my work-around was to just constrain it to a wheel, which seems to work fine, however I do worry that it might cause issues later on.
I am not satisfied that this is the solution, but for prototyping purposes, it works. I think I will create a dummy bone next time to constrain it to.

Hello,

I am working on a similar vehicle a front end loader. I have the vehicle so i can drive it around but I can’t seem to get past the first hurdle of getting my animation to play when I press a key or button and I’m not sure how exactly to hook everything up. I have my animation loaded and know it works.
Would you be willing to take a screen cap of your Vehicle Blueprint event graph? and your animation blueprint event and anim graph?

Are you “moving the bone” on your forklift via an imported .fbx animation sequence?

Thanks!

I don’t have any images right now as I’m not at my development computer, but i’ll try and explain it.

Inside of the Vehicle blueprint (not the animation blueprint). I have created 2 keypress events, one for up and one for down movement (Q and Z).

I have a variable called “ForkHeight” which is a vector.
I have set up a Timeline node that has a float track called “trackfloat” with a max value of 10, min value of 0.

When I hit Q (up), it connects to the “play” input of the Timeline, then from the timeline’s update output, I have a set node for “ForkHeight”.

I have a “Lerp(Vector)” node which ranges from 0,0,0 to 0,0,10, which takes in the “trackfloat” from the timeline, to the Alpha input of the lerp node.
Then from the lerp node, the vector output goes into the “ForkHeight” setter node.

Also, from the Q key press, I drag the “released” output to “stop” on the Timeline.

For the Z key press (down), I simply just drag the pressed connection to “reverse” on the Timeline, and on “released”, once again, I connect to “stop” on the Timeline.

Inside the Vehicle animation blueprint, I created a vector variable once again with the name “ForkHeight”.
Inside of the event graph, I create a “Try Get Pawn Owner” (you may need to untick context sensitive for this to appear), I drag the return value out and cast to the forklift actor, then I drag out from the actor output and “Get ForkHeight”. I then set the animation blueprint’s “ForkHeight” variable to the same value as from the forklift blueprint.
Then if you don’t already have an “Event Blueprint Update Animation” node, create one. Then drag from it’s output to the “cast to” node, then from the “cast to” node, to the setter node for “ForkHeight”.

Now go to your Anim Graph.

You should first have “Mesh space ref pose”, connected to a “Transform (Modify) Bone” for the bone which raises your forks (in my case, it’s called “ForkJoint”). This takes in a Translation vector. Connect your “ForkHeight” variable to the Translation vector. Next, click on the Transform (Modify) Bone node itself and in it’s properties, make sure to set the Translation Mode to BMM Additive, and make sure the Translation Space is set to Component Space.

The next node in the anim graph is “Wheel Handler”, then simply connect this up to “Final Animation Pose”.

Lastly, inside of the fork lift’s physics asset, you need to make sure that the ForkJoint physics type is set to Kinematic (I also disabled gravity).

Then at least in my case, I go to constrain mode, I select the ForkJoint and change it’s Constraint Bone 2 to a wheel or something other than the root joint, and it seems to work fine. However setting to root or none means that the fork will move, but the vehicle cannot be driven, nor does it simulate physics correctly.

That should be it for a very basic forklift, but as you mentioned, you could add your own fork assets and attach them to a socket if you wanted. I don’t know if there are any drawbacks to doing so however.

I find that the problem that I have now with the forklift is that if I lower the forks down on top of a physics body, the physics bodies kind of get pushed into the ground, before spazzing out and flying off into space along with my forklift.
I put in a line trace that is done when I move the forks down to check when the fork is about to hit an object, which stops the forks if there is something it will collide with on the down movement. But it’s not ideal.

Perhaps there is some info too.
https://answers.unrealengine.com/questions/65931/move-bone-with-body.html

I looked at that on answerhub previously, but the solution was too ambiguous and vague, it didn’t really help me at all. And the topic creator didn’t say if the solution even helped him.

It is literally the exact same problem though.

Otreum,

Thanks for the quick and detailed response! I was able to get my bucket arm moving up and down. For my purposes I want the bucket arm to rotate and not translate. I played with it and can kinda get it to work in that it rotates up and down but when it reaches the end of the timeline, it snaps forward a bit and keeps moving all the way around 360 degrees. I have the timeline set to 0-60 and I am using a lerp(rotator) with yaw set at 60. I did change the variables to rotators… not sure if these changes were appropriate?

Thanks,81ba170d2dea85b8cac2867d711701e176505b0d.jpeg

Ok, so I figured out what was making the animation go past the 60 degrees that I wanted. The value being returned from the timeline was multiplying by the lerp(Rotator) value. I had some extra nodes as well from converting my variable from a vector to a rotator and was causing it to flip, gimbal i suppose, but i cleaned that up as well.
graph.jpg

So I have this working and understanding blueprints a bit more but my original plan was to use animations because I have hydraulic shafts, pistons, and hoses to animate along with the arm and the bucket. I can see how to do it using aim constraints like in the physics suspension setup.

Would it be more efficient to do it through an imported animation so the game doesn’t have to constantly update the constraints?

Could the button presses be used on a imported animation timeline the same way?
I’ll do some experimenting myself to be sure as well,
Thanks

Well done! :smiley:

I believe you can do what you are trying to do, but since I have not done it, I am not sure how you would go about it.

I don’t think it would matter too much in terms of performance or efficiency to do it any differently, but I am still very much a newbie. That is something that hopefully a more experienced UE4 user could answer :slight_smile:

'Scuse me for chiming in here. I followed the flow of the described blueprint/anim graph but all I’m getting is my forklift spazzing out around the map and not moving the forks at all. This is what I have so far
Forklift Blueprint
Forklift_bp.png
Timeline
7ae2e29da17dbee40e1b008dc75a83921ce37976.png
Animation Event Graph
58dc7249aefec0e4fd6fcbd3e5d9257c7662166d.png
Animation Graph
b2e6bf41593b09e781f5de2f389935b1d5b00c05.png
Physics for the forks are set to Kinematic, which makes the whole **** thing flop around the map
physics_asset.png
What am I doing wrong?

Inside of PHaT, did you check what your b_forks joint is constrained to? I had to constrain it to something other than the root joint.

Otherwise, everything that you have shown there is spot on correct.

If it’s still not working, I can’t help but wonder if there might be an issue with the naming convention you are using for the root “b_root01” as opposed to “root”. I can’t see why it should matter, but if it didn’t work for me after checking the constraint, that would be the next thing I would try.

I forgot to mention that in your 3d modelling application, make sure that each wheel is moved to the 0,0,0 position, freeze it’s transformations, then move it to where the wheels are supposed to be, so that they actually do have transform values on the x y and z other than 0,0,0.
I knew I forgot to bring something up, because it was frustrating the hell out of me at first :stuck_out_tongue:

I believe this is something that needs to be done with the fork too.

This stops the vehicle from spazzing out…at least it did for me.

Also check out this, this was where I found the solution to the problem :slight_smile:

https://answers.unrealengine.com/questions/59468/vehicle-mesh-phat-setup-requirements.html

Thank you for the reply! I will try all of these and let you know if any of them fixed it.

Really quick, how would I constrain the forks to something else? like should I constrain it to a wheel instead? and that’s something I need to do it Maya correct?

Update: So I tried freezing the wheels at 0,0,0 and then translating them, without freezing after that. I also parented the fork bone to the front right wheel instead of the root bone, and now when bake it all together, it seems to have made the problem worse lol. the Forklift now flies off into pace instead of just flopping around xD

When I say “Constraint” I mean, inside of PHaT, there is a “Constraint” mode.
Check out the documentation, and look for “Editing physics Constraints”.
https://docs.unrealengine.com/latest/INT/Engine/Physics/PhAT/UserGuide/index.html

In Maya (I assume you are using Maya), just make sure all of your bones are connected to Root, and make sure your UP axis is set to Z.

I would suggest checking out some youtube videos, like this one and the video after that.
https://www.youtube.com/watch?v=9yrHqMBynlw

Ok, so I hadn’t been able to work on it this week very much, and I just got back to trying to diagnose the problem. I’ve done everything you’ve told me to do, and I might have isolated the issue.
cast.png
I added the print string just so I could see if it was firing correctly and I got a huge list of “Cast Failed” on my screen. Thoughts?