in Breached, I tried to make the enemies take damage with their own hitbox, but doing that I was unable to make the enemies interact with walls, so I tried to make it so that the enemies spawn a hitbox that follows them everywhere, but the new hitbox is not detecting anything, I even tried logging it(with console.error) to see if they are activating, but I got the names slightly wrong, but no, I got nothing
can I have help figuring out how to solve this?
script link: PlayCanvas | HTML5 Game Engine
Can you send the editor link to me?
How do you damage the enemies?
Press āZā to fire the laser pistol in the direction you are facing
it doesnāt work yet
the laser pistol does, not the damaging
touching the āAlphadelā should damage the player but the damaging hitbox will also do that
and press āCā to dash, I am thinking of using āSā and āXā for something, but I havenāt figured out what for yet.
Thanks, can I see your bullet code?
I mean whatever code makes the bullet.
NVM I found it. This section, I think:
if (this.app.keyboard.wasPressed(pc.KEY_Z)){
isFiring = 1
fireTime = 0.15
if (blastType == 1){
var templateAsset = this.blastUpgrade
var instance = templateAsset.resource.instantiate();
var position = this.entity.getPosition();
var entity = new pc.Entity();
this.app.root.addChild(entity);
if (direction == 90){
entity.translate(position.x + 0.3, position.y - 0.04, position.z + 0.5);
} else if (direction == -90) {
entity.translate(position.x - 0.3, position.y - 0.04, position.z + 0.5);
} else if (direction == 0) {
entity.translate(position.x, position.y + 0.3, position.z + 0.5);
} else {
entity.translate(position.x, position.y - 0.3, position.z + 0.5);
}
entity.rotate(0,0,direction)
entity.addChild(instance);
} else {
var templateAsset = this.defaultBlast;
var instance = templateAsset.resource.instantiate();
var position = this.entity.getPosition();
var entity = new pc.Entity();
this.app.root.addChild(entity);
if (direction == 90){
entity.translate(position.x + 0.2, position.y - 0.04, position.z + 0.5);
} else if (direction == -90) {
entity.translate(position.x - 0.2, position.y - 0.04, position.z + 0.5);
} else if (direction == 0) {
entity.translate(position.x, position.y + 0.2, position.z + 0.5);
} else {
entity.translate(position.x, position.y - 0.2, position.z + 0.5);
}
entity.rotate(0,0,direction)
entity.addChild(instance);
}
I dont think you name the entity. I recomend cloning instead of making a new entity.
It works with the boss hp script as the laser shot is created from a template, so it keeps the name of the template
Sorry, Iāve never worked with templates. Do you use the same collision detection as the boss?
No Arachnadrone has a separate entity for a hitbox because Arachnadrone only appears as a boss once, so I donāt need to add one for him as there is only one and his script prevents him from walking through walls anyway.
Sorry, but I donāt have any more ideas myself, but hopefully this page can help: Collision and Triggers | PlayCanvas Developer Site
oh, thanks, accually, I didnt see it before, but I can use this.entity.collision.on('collisionstart', this.takeDamage, this)
to detect if two rigidbodies touch, and it is reading the function to do or take damage every time I touch it. Although the function is activating, it is not triggering ether of the events in it, so it might not be detecting the whole entity, just the rigidbody component.
Are you sure about this? I recently noticed that when you rename a template in the editor, it isnāt renamed internally. Only the visual name changed. You can check the name of the entity with the console of your browser using something like console.log(entity.name)
.
the name of the template can be changed, but changing the name of the template does not affect the entityās name that was saved in the template, I figured that out while troubleshooting the laser pistol firing and boss HP
To be sure the entity has the correct name, you can set it by script.
entity.name = 'Name';
I have it like that, but the problem is that I have a
this.entity.collision.on('collisionstart', this.takeDamage, this)
that connects to
EnemyMovementAndAttack.prototype.takeDamage = function(check) {
if (check.entity.name == āNormal blastā) {
this.hp -= 10
check.destroy();
} else if (check.entity.name == āQisteā) {
this.app.fire(ādamage Qisteā, this.touchPower)
}
console.error(āhitā)
}
and it is treating everything differently from how I feel like the detection works without a rigidbody.
I even tried it without the
.entity
part so it is just
if (check.name == 'Qiste')
but it didnāt work
should I be using check.other
and not check.entity
I think it is if(check.other.name === 'Qiste'){}
. I am basing this off of what I use if (result.other.tags.has('enemy')){}
1 Like