Mod, Floor, and other blueprints ... available in c++?

I’m looking for common functionalities, but I always end up finding a nice blueprint node that does exactly what I’m looking for.

For example, the simple and very important Floor operation, or Mod. I’d prefer to use FMath or any Unreal class for this.

Is there a way to use them in c++? What do you normally do?

Bonjour darkgaze.
All those functions in blueprints belongs to this header: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Engine/Classes/Kismet/KismetMathLibrary.h

if you see inside the source code from KismetMathLibrary.h, you will see they are using FMath to create all those nodes, so you are doing well

Cheers ma petit friend

KismetMathLibrary is just blueprint wrapper for FMath. Because FMath class is not UObject and can’t be seen by engine reflection system it needs to be wrapped by diffrent class to make node for blueprint and this is what KismetMathLibrary is.

I assume you have problem finding those in API reference. Some lower level math functions are declared in FPlatfromMath which contains low level math code optimized for specific platform (most importently CPU archtecture and it’s instruction set), FMath inherent from it so all of those should be in FMath too and you should used them from FMath as platform specific classes will automatically switch when you build for different platform.

Thanks! I’m really curious how do people search for these kind of things… when you search, it doesn’t really give you anything about Modulus operation, for example. That’s why I found the blueprint. It’s not really logical to end up finding the Kismet Library… So FMod would the the function, then?. Is it safe to use that GenericPlatformMath file in particular, ?

Thanks! Would be FMod the operation to use then? How would you perform a Mod operation yourself? (I mean, the code)

FMath inherits FPlatformMath. But FMath does’t have any FMod operation. FPlatformMath does not exists in the documentation or c++ api (at least, if you try to find it in the website). I’m not used to this convoluted way of organizing documentation. Sometimes I find answers from the staff inside the forum… no official documentation at all about it.

Hi darkgaze, for starters, Visual studio has very good tools to search stuff, for example its very common see questions here about how to use an specific methods inside a class but this questions are kind of dump, type ctrl + f in visual studio and look for results in the entire solution, usually it is incredible fast, then if you are trying to figurate how an method works, you will have a wide variety of answers inside the unreal cpps sources, here a list of tips for you:

  1. Ctrl + F to find something in VS, you can find in the current document, solution or the entire source code, this is the fastest method to know how something really specific works
  2. For instance blueprints are baby c++, you can right click in every node and in the context menu hit go to code definition, will open visual studio for you showing you the code for that node
  3. Actually too much complains about the official docs in the page, but its is incredible useful when you know how to use, in the docs you can type the class or method and usually everything is documented, telling you the module and some details, so if you dont know what is inside what, you can find there the proper module and header, of course you can do the same from visual studio search bar

Cheers again

Get Visual Assist it makes Symbol search lightning fast + lots of other goodies. Theres a 30 Day trial. You won´t regret it pinky promise

Ok nevermind. FMod is available, but docs don’t show the inherited methods. It would be FMath.FMod(x,y)

Yep, thanks! I know it. I wasn’t really expecting to find everything in the engine code. Avoid finding stuff that way is what documentation should be for…

Thanks for the detailed info.
I don’t think searching and having to read the engine code is a good way for fast search, I don’t see it that way. It’s funny to learn that after 3 months of struggling. When you read the guides to start with c++ they never suggest you to read the engine code. I read their docs are new and very outdated, and I have experienced that myself. Really really bad documentation. Sometimes to the point of laughing, other times frustrating. Most of the methods have not enough info, and all of them have no examples at all, meaning they generated all that automatically.
The worst for me is having to find comments from staff members on the forums and answer hub in random places with vital information, nowhere else to be found.

The point of documentation is to help you avoid having to read “other people’s” code. But seems like people work like that here. I’m not used to that, really. I come from Unity, Qt and other frameworks and everything is well organized and updated in the docs. No need to search for examples in code. More human readable, full of simple examples, etc.

I don’t agree that this is what should be done but I understand maybe that’s why there’s not much help around about very basic stuff.

They exist, but under generic implmentation. Again FPlatfrom classes are platfrom specific implmentations and only Generic one is in documentation, when you build FPlatfromMath is replaced with FPlatfrom Name HerePlatfromMath, here entire list of platform classes it had lot of useful stuff if you want to access platfrom OS and hardware information:

But yea i was trying to find Fmod but i could not found Fmod, something wrong with documentation search engine worth bug raporting