Download

Please help - having a hard time...

Hey I am new to the engine and trying to learn.
I am working on a little project that I can’t get out of my head.

I’ve been trying to figure out how I can get a character class that is a cube to move by pivoting on its edge in 90 degree increments.
I was able to put a blueprint together with action mappings that causes my cube to rotate up down left and right but there is no movement associated with it.

I don’t want to achieve movement through single key presses I want to use axis mappings so that I can keep flipping/rotating to move while holding down a key.
I want to constrain the movement to the axis that I am moving along as well so I can’t move diagonally in the plane of movement.

I’ve tried searching for a solution but I can’t find anything that addresses this.

I’d greatly appreciate any and all help with this.

Under the editor button Project Settings -> Input, there are mouse axis settings, this? Thus, that should help to associate movement to your actions.

If you want to achieve continuous movement, add axis mappings to your “Mouse X” and “Mouse Y” and, from their event nodes, just add the axis value to the appropriate rotation axis (yaw for Mouse X, Pitch or Roll for Mouse Y). You’ll want to use a cube whose origin is located at the exact center of the mesh in order to not experience weird rotations.

Thanks for taking the time to reply :slight_smile:

I didn’t clearly explain what I am trying to do. Here is a youtube video of the kind of movement I am looking for except I want to use a cube instead of a cuboid:
https://www.youtube.com/watch?v=G-0VVRm84v4

Hi there Turdle! I just finished putting something together along the lines of what you’re describing. The trick is to think of your character like an elevator rather than a standard player. You want to be able to press a button and get a single instance of movement done, and then once the movement has happened it should check and see if the button is still being held down to do the move again. Do I have that right?

In my case I only wanted the button press to move the guy one single space, so I use a DoOnce node followed by a Branch to double check that my guy has enough room to move. Here’s what that looks like:

When I went looking for these I knew them by the name “Conditions” or “Conditionals”. I’m thinking you’d want to learn up on these options to be able to do a check that your rotation has finished before you allow your Cube to move again, so here’s the links to the details on them:

The next thing you’re going to need is the ability to check your floor to find out if you have the room to move your cube on. That’s gonna take an array, which is basically a grid (it can be 2D or 3D) of any sort of data. It could be lines of text, or a set of blinking lights, or in your case a set of floor tiles. The array has all of it’s data/objects in an organized group and it can spit out information for how they’re arranged when you ask for it. The trick is knowing how to ask, but once you do there are all sorts of things you can do with them. I say it’s a trick by the way because only certain nodes have the right type of pin to connect to them. I’m including both the page on arrays and on the nodes you can use to talk to them:

bde741d9095fd69bb1ad4d5646289736beb1e92c.jpeg

Lastly you’re going to need a variable telling your block where it currently is, and you’re going to compare it to your array when it makes a move. That way your Cube will look at it’s current spot, and know it’s supposed to move whatever that number is plus however many spots away in a given direction. Look up again at the script I put together and check out the lower left hand branch of the SetActorPosition node. Follow that all the way to the end and you’ll see the part I just described. Start following it back up the line. The results of that variable and Math Add node will be compared to your array’s grid using a GET node. That combined information is then used to tell a GetActorLocation where it’s supposed to send your cube when you plug it into a SetActorLocation. Ignore that vector XYZ info block between the two. It’s forcing my actor’s Z coordinate back up because his origin is still inside his chest and I don’t know that you’ll have that problem.

Once you’ve moved your cube be sure to update it’s Current Position variable (whatever you end up calling it) so that the next time you try and move it anywhere it’s notion of where it is in space has been updated as well. If you don’t it’ll always think it was where it started and try and move from there again. I have no idea what that would do, but that’s probably not what you want to happen. Always update your variables when you change something in the game!

Depending on how your animation is handles you may or may not want to start looking up how to get your cube to move through space to reach it’s destination. Using the system I have set up your character will teleport wherever he’s supposed to be. Getting it to not do that is my next big adventure and is gonna take stuff like Delta Seconds and Movement Speed. The most important thing though is that with an Array of objects you can not only tell it to know it’s current location, you can also tell it to know what it’s destination is going to be after you set it. You can then tell the object to update it’s visuals during the move and how long the move should take, but those are hurdles for later.

Get your cube rolling man, and good luck!

Hey, Turdle!

I am working on an example project to show you how to do this.

Too late tonight, but I may be able to get it working tomorrow.

Once it’s done, I will post the solution here.

Awesome! Thank you so much for taking the time to work this out :slight_smile: I wasn’t even setting up my two dimensional array for the floor yet.

I was using a blueprint to generate my floor size and I was going to use a 2D array to store a variable for each tile ranging from 1-6 and corresponding to each side of my cube and then use a boolean statement or something to check if side of cube rotated onto == tile value then all is ok - else destroy cube.

I haven’t figured out how to store a variable to each side of my cube yet but I was thinking maybe adding hidden actors to each side of the cube and assigning a variable to each… not sure if that would even work but it’s what I was thinking of.

If anyone knows of a better way or the “right” way to detect if the side of the cube rotated onto matches the tile rotated onto please don’t hesitate to add your thoughts! :slight_smile:

I got the movement working pretty good. It’s late now, but I can probably package up the files tomorrow night.

For checking the side of the cube, you’d need to check the actor rotation vector and compare that to the normal of the floor (I assume straight up, unless you have uneven terrain).

OK, it’s done!

Full project files for Unreal 4.7.4 are here: http://cybereality.com/files/CubeBlocks.zip

Cube movement is done with the I-J-K-L keys.

Took about 3 days to get it running, but most of that was just me figuring out basic stuff in UE4 (I’m still learning).

Hope that helps.

I would post this in the market place.

Nice work.

Narg

That is super awesome! I’m definitely going to have to check this out! Thanks Cybereality!

Great. Just glad someone will get use out of it.

Thank you this is exactly what I was trying to accomplish!