Applying an impulse to an entity not working


#1

Ok im trying to make my bullet go forward when the player clicks the left mouse button but the click wont even read i put a console.log in and it isnt showing so im not sure what to do here is my code:
https://playcanvas.com/editor/code/612040?tabs=19675869
Here is the project:
https://playcanvas.com/project/612040/overview/animation-test
If anyone can help out and kinda guide me the right direction i would appreciate it.


#2

Use pc.Mouse to check for mouse clicks https://developer.playcanvas.com/en/api/pc.Mouse.html#isPressed


#3

I used that as u can see here. But for some unknown reson it just wont click i tried wasPressed but still didnt work
Ok i kinda see what you meant but when i did that the bullet didnt move it just sat there and im not cloning it so it should just run into something and dissappear


#4

Ok so i fixxed that part button now works but why wont the impulse work?


#5

@yaustar ive done everything i can think of i looked through the forums tried their ideas looked through all the docs and i have it right but nothings happening ill let you know if i find anything else


#6

To do bullets, I would recommend you use raycasts rather than using a rigid body with a large impulse. Usually, physics libraries can’t handle high velocity small objects and they tend to go through things.

Assuming a CS:GO like bullet in first person view, you would ray cast from the camera to a point that is X distance in the direction that the camera is facing (the camera entity forward vector).


#7

I have never really used raycast like that was there any like docs or tutorials on how that works? ive used some of the raycast stuff from some of my other projects but never really made them myself how does this work?