Hello. My game has spikes in the floor. they come out of the floor and can kill the character. I move the part of the model that I find in the hierarchy. But it doesn’t have a solid body and a collider. How do I capture a collision with a character correctly? Here is a sample code.
SpykeController.prototype.upSpyke = function(){
const pos = this.elem.getPosition()
const y = pc.math.lerp(this.middleValue, this.endPos, 0.3)
const v = new pc.Vec3(0,y,0)
this.middleValue = y
this.elem.setLocalPosition(v)
if(v.y > 2.9){
this.isActive = true
this.middleValue = 3
}
}
SpykeController.prototype.downSpyke = function(){
const pos = this.elem.getPosition()
const y = pc.math.lerp(this.middleValue, this.startPos, 0.009)
const v = new pc.Vec3(0,y,0)
this.middleValue = y
this.elem.setLocalPosition(0,y,0)
// console.log(this.entity.rigidbody)
if(v.y < -1.9){
this.isActive = false
this.middleValue = -2
this.timer = 0
}
}