#Replacing Vector3.new with vector.create

1 messages · Page 1 of 1 (latest)

cobalt elm
#

I'm going to replace every single usage of Vector3.new() (18 results) with vector.create() in my game. Is this risky?

mental cedar
#

not risky but is a change that unless you're creating a vector3 100 times every frame is not going to be even noticeable

grizzled ravine
#

not exactly risky, just really dumb, you're trying to 'optimize' something that is only used 18 times, seems like a complete waste of time and effort that's probably going to come back to bite you later on if you do this. just focus on making a game first, optimize it after you have it working if you even need to optimize at all. https://en.wikipedia.org/wiki/Program_optimization#When_to_optimize

"Premature optimization" is a phrase used to describe a situation where a programmer lets performance considerations affect the design of a piece of code. This can result in a design that is not as clean as it could have been or code that is incorrect, because the code is complicated by the optimization and the programmer is distracted by optimizing.

When deciding whether to optimize a specific part of the program, Amdahl's Law should always be considered: the impact on the overall program depends very much on how much time is actually spent in that specific part, which is not always clear from looking at the code without a performance analysis.

In computer science, program optimization, code optimization, or software optimization is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources. In general, a computer program may be optimized so that it executes more rapidly, or to make it capable of operating with less memory storage ...

#

as an example lets say you do this and continue on your merry way using vector.create everywhere you would otherwise use vector3.new, and then you need to do 100 raycasts. which take vector3's. you've not only wasted your time with vector.create but you also doubled your memory usage, plus the cpu usage wasted on the conversion. don't prematurely optimize.