You are right. I went ahead and tried it as well, and a single line shows 2 lines for some reason. I thought perhaps those are 2 points, that compose a line. After all, points also belong to “Other primitives”:
However, Spector shows it as 2 lines and 0 points:
Not sure how to read it. Perhaps I can use my epic summoning spell to summon @mvaligursky, a lines master
Sorry to bother you with this, but I’m still having trouble moving with dt.
Because I assumed it was due to my script, I continued to search.
However, now I have created a simple object with a script with only this in the update:
// update code called every frame
MoveTest.prototype.update = function(dt) {
this.entity.translateLocal(0, 0, -2 * dt);
};
The object does not move smoothly!
Because it works well in another project, I really don’t know where to look for the problem anymore.
I’ve had a quick look, and the issue is in the main update loop, which does all the updates.
// update code called every frame
Player.prototype.update = function(dt) {
this.updateAnimation(dt);
this.updateClimbing(dt);
this.updateCollision(dt);
this.updateFalling(dt);
//this.updateInput(dt);
this.updateJumping(dt);
this.updateMoving(dt);
this.updateSensors(dt);
};
First, don’t create new classes in these update functions. For example, in your updateMoving():
...
var originalRotation = new pc.Quat();
var finalRotation = new pc.Quat();
You would want to create them on initialize, instead of on every frame.
The main cause is however the updateSensors() method in your Player_Sensors.js. I counted at least 14 raycastAll() rays that you fire each frame, and then iterating over the results of each raycast. Since each raycastAll can potentially return many hits, this method can become expensive very quickly, and start tanking your CPU. Lower end phones will definitely have an FPS stutter.
I would advice to reconsider using as many raycastAll(), or even dropping them completely and using some other, less expensive ways, like trigger volumes.
Thank you for your time and explanation! However, even when I deactivate all updates, I still don’t have a smooth movement of the cube with the test script.
As for the sensors, I just followed the advice in this post:
I’ve created a new project with only a camera in it. I also see an FPS drop with lower-end device setting (slows down CPU), even though there is nothing to render. Perhaps, @yaustar could look into it.
Its just a simple setting in Chrome dev tools (upper right corner):
The setting is relative to your computer, and it just artificially slows down your CPU by 4 or 6 times. Not really matches the real devices, but approximates the performance.
On my mobile (iPhone X) it’s working fine to.
But my orginal build of the game that you played already is working also fine on my laptop.
So I realy don’t know where to search.
Maybe I have to start a new project again, but I like to know what causes the problem…
It seems that with making the screen smaller everything runs smoothly indeed! That explains why it works smoothly on my mobile.
But what I don’t understand is that I only have this problem in this project. I have another player movement project in which the player also moves smoothly on full screen…