Touch Execution Faster in C than Javascript?

Hey guys. First off I want to mention I tried searching for my particular issue, and ended up with mostly “Is C faster than Javascript” threads speaking generally on the performance of both…I’m not asking this (necessarily).

I have a basic script for rotating an object when the user slides their finger around on the screen (iPad mini). As I was coding, I converted a C# version of the code to JS (for no real reason other than I prefer JS), which in the end is identical. I can’t stress this enough. Line for line it’s completely identical other than changing ‘void’ to ‘function’, rearranging how variables are declared and the ‘f’ at the end of floats; the JS version of the script works exactly as intended…ish…

The problem with the JS version of the script is, that if I run my finger slowly enough over the screen, not a bit of input is detected. The finger must be moved briskly and over a slightly greater distance for the object to begin rotating.

The performance of the C# version of this otherwise identical script is vastly superior, allowing for input to be detected immediately upon touching the screen (as expected). I barely ‘roll’ my finger in one spot on the screen and you can see the object respond.

Just to be clear, though I’m not certain this is important but the C# script is located in the /Standard Scripts folder, and the JS script is in my own /_Scripts folder. I understand that scripts in /Standard Scripts are compiled first, but I can’t see that being the problem here.

Short question then…would there be a case where two identical scripts, one written in C# and one in Javascript, performs better in C# than JS?

Thank you!

-Steven

There are marginal differences in performance in some circumstances, but nothing that would cause anything like you describe, which seems to be actually about a difference in behavior rather than performance as such. It may be that you’re missing something after all, but without the scripts it’s impossible to say.

–Eric

Hey thanks for the quick reply Eric!

You asked for it, so here they are! :smile:

C# Version

Javascript Version

I’m not seeing it, but if you do, wunderbar!!

:smile:

-Steven

inputX and inputY are floats in C#, but ints in JS.

–Eric

:sweat_smile:

Do you know how many times I went over this!??!

Haha, my gawd, thanks Eric!

sigh

-Steven

EDIT: The oops emote doesn’t seem to work? Rest assured…its a BIG oops emote :smile: