But there is a big problem with it : my hero doesn't follow a straight path relative to its current rotation
Can anyone tell me what's wrong with it?
Why would he?
You didn't make him follow it and he didn't bother to do so on its own
Question 2 :
Which is the best way to fire a projectile at a specified target so that it will produce smooth movement ?
Get a start point, end point. Subtract end point from start point and normalize the new vector. You'll have a direction in which your projectile should go. Then you just multiply that direction vector by velocity and delta time.
Or you can use irrlicht's 'fly straight' animator.
Look into rotationToDirection() and use its return vector scaled before sending it as the second parameter to move().
I don't recall if you'll need to normalize it first.
Answer 2:
Subtract the shooter's position from the target's position. (Otherwise, you'll shoot backwards). Then call move() on the projectile the same way you did to the hero. What the projectile does when it hits or misses is up to you.
"Computers don't make mistakes! What they do they do on purpose!!"
Look into rotationToDirection() and use its return vector scaled before sending it as the second parameter to move().
I don't recall if you'll need to normalize it first.
Oh my god , thank you , that's exactly what i wanted and works as expected !!!
As for question 2 :
Get a start point, end point. Subtract end point from start point and normalize the new vector. You'll have a direction in which your projectile should go. Then you just multiply that direction vector by velocity and delta time.
Or you can use irrlicht's 'fly straight' animator.
Subtract the shooter's position from the target's position. (Otherwise, you'll shoot backwards). Then call move() on the projectile the same way you did to the hero. What the projectile does when it hits or misses is up to you.
Although, I would not have chosen the name 'source' to represent the position of a moving projectile , as long as your update code has access to 'source', I do believe that should work.
Hopefully, I understood that correctly and that helps.
"Computers don't make mistakes! What they do they do on purpose!!"
By the way , im facing another issue.
I can't get the directx drivers to work but the opengl.I think its because of codeblock's compiler , because i can use fine all drivers with ms vc .