Issue with rotating an object in increments - player controlled
Hi there, I'm currently having trouble implementing a game mechanic in my game prototype. I want to rotate an object in the game through player input, but rather than it being a simple animation through matinee I want it to be the core mechanic allowing the player to rotate this object at any point during the game along any of the axis.
Currently, I am working on a simple pyramid object to get the mechanic working. I want it to rotate at 90 degree increments by any axis, one at a time. This will be done via player input, for example: Pressing up once to rotate it 90 degrees through pitch. I want it to be able to go in any direction at any time. Only ever in set intervals of 90 degrees, not free flowing.
Currently, I have a blueprint that makes the object rotate by 90 degrees along Pitch. It works fine at first but then changes direction when it shouldn't do. I want it to keep rotating in a continuous direction, not come back on itself.
Here is a GIF of the current problem. http://i.imgur.com/HbZfcPN.gifv
asked Nov 21 '14 at 02:42 PM in Blueprint Scripting
I recreated your blueprint to see if I was able to reproduce the outcome you were experiencing which was indeed the case. I tried tweaking your set up a bit to test out different outcomes all with different and varying results. I was almost able to get it to work with the "Move Component To" node, but as soon as I went from 180 degrees to 270 degrees the mesh did some twisting and turning and re-positioned itself instead of a clean rotation of pitch. This is something I will look into further because it seemed to only happen with Pitch, and not the Yaw or the Roll factor.
That being said, I was able to get the correct outcome of what you are looking for (hopefully) by adding a couple of nodes in the construction script and changing up the logic a bit. We still are using a Timeline and Lerp in between a rotation variable we create and a float vector. Follow the instructions given and use the images on this post as reference on how to set up your blueprint correctly.
Steps to Follow:
After getting everything connected, double check to make sure it matches the images and press play. Hopefully when you press the key you have assigned to the rotation, it gives you the desired effect. Keep in mind if you mash the input key it will continually reset the rotation position until it has completed its rotation.
I hope this helps clarify some of the questions you had and gets you on the right path!
answered Nov 24 '14 at 03:17 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here