For some reason the raycast won’t fire.
// More information: http://developer.playcanvas.com/en/api/pc.RigidBodyComponentSystem.html
var Wallride = pc.createScript('Wallride');
var tilt = 'hi'
Wallride.prototype.initialize = function () {
this.entity.collision.on('collisionstart', this.onCollisionStart, this);
this.entity.collision.on('collisionend', this.oncollisionend, this);
this.leftPosition = this.entity.findByName('raycast_left').getPosition();
this.eulers = new pc.Vec3();
};
Wallride.prototype.onCollisionStart = function (result) {
if (result.other.tags.has('wallride')) {
console.log('1st hit')
this.doRaycast_left()
}
};
Wallride.prototype.doRaycast_left = function (screenPosition) {
console.log('func started')
// The pc.Vec3 to raycast from
var from = this.entity.getPosition();
// The pc.Vec3 to raycast to
var to = this.leftPosition;
// Raycast between the two points
var result = this.app.systems.rigidbody.raycastFirst(from, to);
// If there was a hit, store the entity
if (result) {
console.log('2nd hit')
tilt = 'left'
}
};