Hi,
I am working on a game and need an advice for a good game experience.
Can someone give me an advice on how to hide in this video sequence the street lamp which appears during camera rotation between the third camera view and the player located with the punk character ?
May be something around raycasting ?
Thanks
Yes you can use raycasting. You can cast a ray from the camera to the player using the raycastAll method which returns an array of entites that were hit by the raycast. You can then hide their models using entity.model.hide().
1 Like
Ok,
I tried something but the results are strange.
var from = this.entity.camera.screenToWorld(window.innerWidth*0.5, window.innerHeight*0.5, this.entity.camera.farClip);
// to player position
var to = this.app.root.findByName('Player').getPosition();
var result = this.app.systems.rigidbody.raycastAll(from, to);
// If there was a hit, store the entity
if (result) {
console.log(result);
}
The project is here : https://playcanvas.com/project/736977/overview/lockdown
Try to replace farClip with nearClip