0

How do I set JUST a single axis of euler rotation using bolt?

Simon Keating 3 years ago updated by Zefugi 3 years ago 6

I can find a unit for setting all the x y a z togethor but lets say I just want to change the y angle and leave the other axis how they already are. I cant figure it out. Thanks

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+1

This should do the trick:


Note that Unity also has a built in function Rotate(axis, angle) for rotating by a number of degrees:


Perfect. Thank You

+1

Maybe there should be a single unit that does this in Bolt. Anyway, I made a Super Unit for this that can set a single rotation axis on a gameobject to a specific value.. 

Users input the Gameobject, Axis and an angle of rotation. All other rotations (the two that you don't choose) are unaffected. As an example of usage, I am using this when I want my player character to point towards (using LookAt) an object, but at the same time maintain his z rotation. So I can now just use:



The nuts and bolts are here. Please feel free to download and use.

SetSingleAxisRotation.asset



P.S.. I only tested it in my own case scenario, but fingers crossed hey :)

Cheers

Interesting implementation.

This might be of interest to you: https://support.ludiq.io/communities/5/topics/1290-extention-methods

Yeah, I'm new to this so it might be completely nuts (its massive) but it seems to do the job. Its crazy though how in code I can basically do this in one line. I'm currently weighing up the pros/cons of Bolt and this kind of thing definitely goes against Bolt. But there are lots of positives, for example, at least now I have this as a super unit so I will never have to do it again.

Bolt is just a tool and it has it's proper use and limitations. Mixing it with C# makes it 10x as powerful. I'd like to put stuff like this in extension methods in C#, but making a Flow Macro like you did is the best we can do for now.

For me, after 32 years of programming in everything from assembly to basic, Bolt is slower when producing logic, but faster when designing logic and debugging logic, i.e. when using the state machine Force Enter/Exit functionality, I can prototype and test multiple designs rapidly, before I settle on a specific implementation and fill out the flow macros.

Bolt is not unique that way, but I think it feels more polished and intuitive than the competitors.