How to make an object freely rotate on an axis?

I am developing a building game, and I am working on a rotating part that attaches to what you hit, and then it can rotate. So if you attach it to a cube, then attach a wheel or something to the rotator, it should be able to be pushed around like a cart and the wheel will roll. So basically building vehicles with many parts.

How could I make a part rotate around a single axis so a wheel could be attached to it?

Thanks in advance.

Replying to your specific question - you can add Rotating Movement component to any actor. Create an actor and then add a that component.

The bigger issue might be “building a vehicle with many parts”. I would suggest simplifying or separating the two game separate game elements. You can have one part of the game where you “build” and another where you use the object. You can swap out meshes for the final product at the end.

That helps, but I mean that I want it to not be a set rate, so if you walk into the vehicle for instance, the wheels will roll just by physics because the rotating part isn’t constrained to a specific rotating motion. Like not having a motor, I want it to freely and loosely rotate based on being pushed around. I will deal with forced/set rotation later.

It sounds like you’re after a vehicle type setup. In which case, have you looked at this and this? You can create a new project, choose Vehicle Template. Copy the created pawn so you have two on the map, then use one vehicle to “bump” the other. Is that the type of interaction you want?

Not really. I want it to be like scrap mechanic. Adding wheels on the fly, thrusters, crazy stuff like that. Like space engineers, no in game editor, just simple adding wheels or seats the same way you place blocks in Minecraft.

Here is the game btw, in development, on Itch.io: https://jtrocks55.itch.io/universe-constructor

Nice - I like it. Keep up what you’re doing :slight_smile:

For your game, I am not sure I entirely understand your specific use case so I can only offer generic advice. Quite often in games the developers “fake” outcomes. If you want to have a wheeled cart that you can push around, create an actor that you can only move along the XY plane. Then add “wheels”. You can setup rotation speed on the wheels with the RotationMovement component based on forward velocity. That way the wheels will rotate with variable speed depending on the speed of the cart, but it will not be 100% pure physical simulation. It will look like the cart is moving on its wheels so you get the right outcome but without complex physics simulation.

Otherwise, you can still used wheeled template to learn how to create a wheeled vehicle. Just don’t apply any throttle/steering and it will behave like a dumb cart.

Thanks! :slight_smile:

Ok, that helps some, but it is still not the direction I am going. I do not want to make anything preset, I want the player to build everything. So for example, let’s say the player needs to get somewhere quickly. What he or she would do is build a cart with blocks, just like Minecraft, but then add wheels to the side of it: here is a demonstration

What I am wanting is this: the little grey things I attached before I added the wheels, I want them to rotate. So you can add wheels on top of those and the wheels will turn.

Actually I think I figured it out. This is the first result: Dropbox - File Deleted

I love it! How did you end up doing it ?

Thanks! :slight_smile:

So I just gave the rotator a Physics Constraint Component, and set up some nodes to attach it to the hit object via the physics constraint, then it would rotate freely. Then set up a physics constraint on the tire and made it attach to the rotator the same way. Now I have a working vehicle building system! All that is left is to make a way for the blocks to snap to the vehicle’s grid and attach to the vehicle instead of the world.