What is mean ( hard coded )

What is mean ( hard coded )

hard coding means that you add some element in your code that you can not change without changing the code itself.

for example, if you want to make that your character moves forward with a specific speed:

AddActorLocalOffset(MovementDirection * 4, true);

in this case, the β€œ4” is the speed of this character but the problem is that it’s hardcoded. So you can not change that speed in any other way than changing the value in code which is bad for flexibility for most cases.

So to fix this you need to add this in the header file:

UPROPERTY(EditAnywhere)
Speed = 4;

and then:

AddActorLocalOffset(MovementDirection * Speed, true);

This exposes the Speed variable to the editor which makes you able to change the speed of character without changing the code itself in the editor. So it not hard coded in your code anymore. I hope this explains what hard coded means.

1 Like

You are the best one

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.