Hello Everyone! I need some help )
How to create this function in C++ which has a return type bool…
Hi Alexa.kl,
Here’s an example in another Forum post - he’s asking a separate question, but the code that’s used there looks like a good example:
Thank You very much for the reply.
I got an idea from the post is:
.h
UFUNCTION()
virtual void RollingSteering (bool& InScope);
Please correct me if I am wrong. Thank You )
That is one way to do it - the passed in bool will be set to the correct value on return.
Another way you can do it which doesn’t need a bool passed into the UFUNCTION is:
UFUNCTION()
virtual bool RollingSteering();
And in your c++ part, it would “return ‘myBool’;” as the last statement in the function.
Thank You very much, it help me a lot… Thank You for helping me in my learning progress )
Can I pass float and other data types in this function?
such as
UFUNCTION()
virtual bool RollingSteering(float Axis, FRotator SteeringRotator);
Yes you absolutely can - it can be very useful to do so.
When passing in values such as FRotators and FVectors - rather than pass it directly like that, it is better practice to pass a reference to it instead (then, the parameter stack is filled with just pointers to the objects rather than the objects themselves which can be quite large).
So you can do either:
virtual bool RollingSteering(float Axis, FRotator& SteeringRotator);
or
virtual bool RollingSteering(float Axis, const FRotator& SteeringRotator); // doesn't allow it to change
Thank You for sharing the knowledge, it really helps me and others to learn.
Thank You very much.