Hello am having a problem with my projectiles not shooting straight when my character is moving. When the character is standing it goes perfecting straight but when moving the player’s momentum makes it only goes in a single direction?
here is video showing what’s going on and my blueprint. Bullet example - YouTube
If you want your projectile to move along with your character, you have to add the character’s velocity to the projectile once it’s spawned. Your projectile’s velocity only has a Z component to it, I believe.
That didn’t seem to do anything still have the same problem
Can you show some screenshots of the BP where you spawn the projectile? It’s too blurry in the video.
I see you have some variables exposed on spawn, and some of them deal with speed. Maybe they interfere with each other. So instead of adding the character’s velocity after the spawn node, try adding it in the Bullet BP.
still same result instead of firing up it fires up and to the left or right depending on which am moving. It seems to me the players momentum is is interfering with my projectile movement component some how.
It doesn’t fire to the left or right, it fires straight up. Relatively to the ground it stays in the same place, it just looks like it’s moving because your character and the ground move.
Does Get Player Character get the character you need? Try casting it to your character class and find out. Or just print out the characters velocity to see if it’s more than 0.
ya I got the right character it’s velocity it greater than 0. I wonder if it’s the set physic linear velocity node I am in paper2d and do It askes for a bone name and paper2d sprites don’t have bones. There another node I can use?
It always asks for the bone name, that’s not the issue here.
Can you show the bullet BP?
A few comments about the overall BP:
- On Begin Play you set the Player Ref, so you don’t have to Get Player Character anymore, you can use that reference.
- In the Damage node you have HP to Subtract pin, but you subtract the damage manually and pass the result to the Damage node, are you sure that’s how it is supposed to be?
Now to velocity: You’re setting Max Speed and Initial Speed on Begin Play with the Projectile Movement as Target. As far as I’m concerned, the projectile movement updates on Tick, so I believe it overrides the movement that Set Physics Linear Velocity.
Maybe, if you want your projectile to move with the character, you can calculate the direction prior to spawning the projectile: in the Spawn Transform Rotation, use not the pure rotation of the Arrow, but turn it by a certain amount based on the character velocity.
I’m not sure if I’m right, but I guess that using a ProjectileMovement component applies the Initial Speed to the X vector only, so additional velocity won’t work.
So am getting some really when I use the velocity to rotate the bullet just spawns in really random locations I think may be doing some math wrong how would I rotate using the player velocity?
ya that didn’t seem do anything still not moving with the player am kinda out of ideas at this point
I had the same problem. While moving the character, the projectiles were not going straight when shooting up. Fortunately, I found a solution that worked for me.