Download

C++ variable issue

Hello Guys,

Firstly, I am very newbie in C++.

I am writing some code like below in my cpp file:



	float xPosition;
	float yPosition;

	xPosition = FMath::RandRange(6, 14) ;
	yPosition = FMath::RandRange(6, 14) ;

xPosition variable always taking a number between 6 and 14 but yPosition variable value isnt change. it is always: 0

What is my mistake?

Can someone help me?

Thanks in advance

You should be using FMath::FRandRange for floats, that might be the start of problem. RandRange returns integers :slight_smile:

Hi TheJamsh,

I found my mistake and thank you for your reply. Your answer resolved my problem which wouldn’t have yet. :slight_smile: