Spawning problem

I cannot figure out why my spawners are not working, I just get a message in the console stating
Capture d’écran 2025-04-19 à 00.13.18
that I have 2 enemies at the begining… this afternoon I’ll had it working, I have no idea what changes messed up the entire project. When they will spawn I’ll face another issue, bulets are not destroying enemies also… they were working allright on the enemy before my spawning and animation trials… The code should be pretty readable, all in english with ots of comments…
here is the project: https://playcanvas.com/project/1331252/overview/jeu-des-relatifs-214

Hi @magicdidier!

I’d recommend again to first add it to a parent entity before setting it’s position. Maybe try logging the enemy’s position to make sure it’s being placed correctly.

If you set the position of en entity with an dynamic rigidbody you cannot use setPosition(), setLocalPosition(), translate(), translateLocal(), etc. It will only set the position of the entity, so collision will not work as expected anymore. Maybe it’s an idea to use a kinematic rigidbody instead?

Also just a heads-up, the template attribute on the positive spawner is empty.

By the way, the spawners are disabled in the editor. Do you enable them somewhere? (Scripts are not running on disabled entities).

1 Like

LOL I was so tired that I did’nt noticed it !!! the spawner is working allright now, the enemy movement too. I ll investigate further collision with your kinematic recommandation
thks again

I have made changes for kinematic rigidbody, but there is a very strange problem, my bullet are destroyed because too slow, following console message ligne 246, but this ligne no longer exist in playerMove.js??? I am confused
https://playcanvas.com/project/1331367/overview/jeu-des-relatifs-215

I can’t find a script called playerMove.js. If you meant Player.js, the line might appear missing due to unsaved changes. (The line from the current version might be causing an issue).

image

If you changed some script names, you probably need to re-parse and re-add the scripts. (Remove scripts that no longer exist from entities).

This is quite normal because I am working on it right now, and I am trying things to figure out whats going on. There is one thing that puzzles, me, even when I change the name of the scripts, delete them, replace them, the old scripts are still in use in the console, theer isno way I can start for fresh scripts… there must be one major thing in playcanvas that I have completly misunderstood. At that point I am thinking of starting a new fresh project from scratch to understand, script added after script added what’s wrong with me

You could try to use the hierarchy search option (left top corner) and search the old script name (filter on script name). Also if you use templates, don’t forget to update them.

I have restarted all from scratch, there was too many possibility of error with my previous build
I have cleaned up all scripts and reassign responsabilities

  1. player.js just makes the player move and clone bullet
  2. Spawners spawns enemies
  3. Enemy moves move enemies
  4. Bullet, check for collision, explosion, and should move the bullet.
    At that point no more error message in the console, enemies spawn, move allright, turret turns, shoot bullet right in front of the guns, bullet disappear after 1second as planne, but they just won’t move…
    Which I understand is quite often the case with kinematic bodies

As far as I know there should be no reason kinematic rigidbodies can’t move.

Can you share the new project please?

I made it!!! spacecraft are destroyed by bullets, now my new main issues are the explosion system which don ’ t work, and the numbers on the ships which are not generated. So happy to share the project with you : PlayCanvas 3D HTML5 Game Engine

New problem ! lightning in bullet cause problem, and lightning in explosion also, I get tje message error : Vertex attribute [vertex_normal] at location 1 required by the shader is not present in the currently assigned vertex buffers, while rendering [Pass:RenderPassForward RT:WebglFramebuffer | Camera: Camera, Layer: World(OPAQUE) | Node: explosionTemplate, Material: Default Material]
no idea why…

I just checked the original project and I can’t reproduce this issue.

Where did you found the explosion effect?

I found it in the playcanvas examples, PlayCanvas 3D HTML5 Game Engine

Alright, but the error isn’t in the example project, right? No idea what could be causing it, I have no experience with shaders. I’d suggest opening a new topic for this.

By the way, the up and down controls are inverted?

Other than that, great progress! :rocket:

thanks, it is not over yet, cause the text on the crafts are not showing up, then i need to start adding code for scoring, and I may change a bot the movement of the enemy to make it more interesting. I vole this topic, and open a new one. Thks again albertos

1 Like