Hey fellow AGKlers
I want to shoot an arrow in the direction the mouse is pointing.
To shoot the arrow I use SetSpritePhysicsImpulse() .
It's working pretty fine - at least as long as the framerate stays the same.
Somehow it seems the force applied to the arrow sprite gets stronger the higher the fps are.
The force applied to the character sprite using SetSpritePhysicsForce() and - and that's kind of strange - the force when jumping the character using SetSpritePhysicsImpulse() are not affected by this.
Due to the fact, that the character behaves as it should, I think, the problem is within my code.
Here is a short video showing the problem in action (inline video seems not to work):
https://youtu.be/czydbMHhiZs
This is the main code I use to shoot the arrow:
projectile as TPlayerProjectile
projectile.sprite = CloneSprite(player.sprite_shoot_mode[2]) // this is the arrow-sprite
projectile.type$ = "arrow"
SetSpriteGroup(projectile.sprite, -500)
SetSpritePhysicsOn(projectile.sprite, 2)
SetSpritePhysicsMass(projectile.sprite, 5)
SetSpritePhysicsIsBullet(projectile.sprite, 1)
arrow_angle# = GetSpriteAngle(projectile.sprite)
r# = (GetSpriteOffsetX(projectile.sprite) + GetSpriteOffsetY(projectile.sprite)) / 2
x1# = (r# * 1) * Cos(arrow_angle# + 90) + GetSpriteXByOffset(projectile.sprite)
y1# = (r# * 1) * Sin(arrow_angle# + 90) + GetSpriteYByOffset(projectile.sprite)
x2# = (r# * 1000) * Cos(arrow_angle# - 90) + GetSpriteXByOffset(projectile.sprite)
y2# = (r# * 1000) * Sin(arrow_angle# - 90) + GetSpriteYByOffset(projectile.sprite)
SetSpritePhysicsImpulse(projectile.sprite, x1#, y1#, x2#, y2#)
Do you have any idea what is causing that behavior and how I can fix it?
I already tried manipulating StepPhysics() based on the current fps but to no avail. And since the forces on the character are fine, I don't think that is the problem.
Codin' regards
Daniel
Yes, I am aware that I sound like a caveman to native english speakers