Hello, i updated my code and the ammunition went wrong it is shooting in a wrong direction even if i change it’s direction
@Miggy_Dacillo This is a very common problem that has been answered in the forum. Maybe this post will help you solve your issue.
I tried to do what they did but mine is still the same
@Tirk182 I tried to follow what they did but mine did not have any changes
@Miggy_Dacillo I tried to have a look here at what you have so far. It seems like the camera and your character have been removed from your project so there is no way do some quick debugging. Could you add everything back so someone can have a look?
Hello, I already updated it but instead of fixing it, it doesn’t shoot at all anymore. DACILLO_MIDTERMS_MNMTECO | Editor (playcanvas.com)
@Albertos oh thank you but it says it has an error? in line 17
You need to parse the script first and then add the correct entity to your attribute.
how can I fix the bullet shooting in a wrong way
@Miggy_Dacillo What I can see so far is that once you start your game the ball just drops to the ground. If you are cloning an instance of the ball to shoot you will need to disable it in your entity. After the first one drops I can see that you are launching a ball however it is not in the direction of player forward. Here is a code snippet that may help.
this.force = new pc.Vec3(); this.force.copy(player.forward); this.force.scale(this.power);
So the entity.forward in you ballThrow script will have to align to player forward not BulletEmitter forward I think. You are very close to getting this to work. Inside your ballThrow script is where all the action is happening.
I changed my script into what you give to me but there is an error which says that ‘player is not defined’ how can I fix this?
@Miggy_Dacillo Please return your player.forward to this.entity.forward. I understand a bit better what you are seeing. My question is how are you getting this number inside the get?
var bulletAsset = this.app.assets.get(107777787);
Is this correct?