Hi All
I am in the middle of a game jam, so things are subject to change, but my game’s FPS significantly drops after not that long of playing. If someone can please check this out that would be great!
Hi All
I am in the middle of a game jam, so things are subject to change, but my game’s FPS significantly drops after not that long of playing. If someone can please check this out that would be great!
It’s a solid 60 FPS for me.
Just figured it out, thanks for the test though. It fixed itself for a bit, but it got really laggy after a while. It isnt deleting the entities correctly.
So the kill script:
var EndlessRunnerPopulationControl = pc.createScript('endlessRunnerPopulationControl');
EndlessRunnerPopulationControl.attributes.add('platform',{type:"entity"})
EndlessRunnerPopulationControl.attributes.add('message',{type:"string"})
// initialize code called once per entity
EndlessRunnerPopulationControl.prototype.initialize = function() {
this.entity.collision.on('triggerenter', function (entity) {
console.log(this.message)
this.platform.destroy();
},this);
};
// update code called every frame
EndlessRunnerPopulationControl.prototype.update = function(dt) {
};
// uncomment the swap method to enable hot-reloading for this script
// update the method body to copy state from the old instance
// EndlessRunnerPopulationControl.prototype.swap = function(old) { };
// learn more about scripting here:
// https://developer.playcanvas.com/user-manual/scripting/
Works as intended for a bit, keeping the amount of platforms at 5, but after a while it stops working. Any ideas why?
Hi @Codeknight999!
I didn’t check your project yet because I’m on my mobile at the moment, but I guess this.platform
is a template entity that you clone every time?
If that’s the case, maybe you don’t destroy the correct entity?
It isnt a template, it is just an entity
I mean an entity that you use multiple times, like cloning. By the way, it’s also running at 60 FPS on my mobile for at least a couple of minutes, so what do you mean with ‘after a while’?
Let me send a vid, give me a seccond.
I cant record a vid, but I started a stop watch and it seems it ironed itself out.
I pressed the w key to jump for quiet a while and then the frame rate dropped dramatically. At that instant there was an console message that there were more than 254 clustered lights.
If the issue comes back ill unSolve this and ask.
So it is the jumping
My jump script hast been working properly, let me take a look.
How would I fix it?
Also, here is my jump code. I modified and cut out a lot of another pice of code:
var PlayerMovement = pc.createScript('playerMovement');
PlayerMovement.attributes.add('jumpForce' ,{
type : 'number',
});
// initialize code called once per entity
PlayerMovement.prototype.initialize = function() {
this.moving = false;
this.jumping = false;
this.entity.collision.on('collisionstart',this.onCollisionStart, this);
this.entity.collision.on('collisionend',this.onCollisionEnd, this);
};
// update code called every frame
PlayerMovement.prototype.update = function(dt) {
this.movePlayer();
};
PlayerMovement.prototype.movePlayer = function(){
if(this.jumping == false){
if(this.app.keyboard.wasPressed(pc.KEY_W)){
console.log('Applying force');
this.entity.rigidbody.applyImpulse(0,this.jumpForce,0);
this.jumping = true;
}
}
};
PlayerMovement.prototype.onCollisionStart = function(){
this.jumping = false;
};
PlayerMovement.prototype.onCollisionEnd = function(){
//this.jumping = true;
};
// swap method called for script hot-reloading
// inherit your script state here
// PlayerMovement.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/
The error says that in Character script initialize function you are subscribing to an event with a missing argument. So pass the required argument.
I just fixed that.
I think that fixed the lag, but the jump is still not working properly.
No the lag is still there, and eventually Ammo crashes.
I would add some more console logging to check that collisions/triggers are occurring when you expect the to, and entities are created/destroyed when you expect. It looks like you are leaking resources and eventually things start to fail.