Hello,
I am implementing shooting an arrow and I already made a post about it here: https://community.rpgjs.dev/d/175-shoot-arrow-in-place-of-cursor/8
but this solution has two flaws:
- I can't get a working calculation for rotation to make it look good (it looked good with speed = 20), check the video below
- When I rotate an arrow on the client side the hitbox is not accurate because it's not rotated on the backend which detects collisions
I couldn't find a solution using the current features of the engine, so I decided to try to tweak this.
and here is PR: https://github.com/RSamaium/RPG-JS/pull/274
This gives the possibility to set an angle or rotation on the backend object like this:
event.angle = 50
// event.rotation = 100
and next read this in the spritesheet definition like this:
@Spritesheet({
framesWidth: 1,
framesHeight: 1,
textures: {
[Animation.Walk]: {
animations: (direction, angle, rotation) => anim(direction, angle, rotation),
},
[Animation.Stand]: {
animations: (direction, angle, rotation) => anim(direction, angle, rotation),
},
},
})
export default class BulletSpritesheets {
}
I know it's probably not the best solution.
Firstly I wanted to add AnimationParamsManager and apply this to the RPGPlayer to make the code more modular, but the hitbox is calculated in the AbstractObject so I put there this logic.
Let me know if it's an acceptable change to the engine.
There is also sample4
directory where you can check how it works and below is the video:
but still, two issues persists:
weird hitbox detection - it looks like there is some point above the character that is detected as hitbox (arrow disappears) - I have one guess - maybe it is because there is an invisible top component that is possible to hit? The same result I got with HPBar enabled
The arrow is flickering in some directions. When it is rotated close to the left, right, top, and bottom it looks smooth, but when it comes to diagonal directions the arrow starts flickering. I tried to investigate it by:
- wrong rounding float numbers - I was playing with different algorithms without a result
- refresh rate (?) - when I changed server.tick to interval(10) it looked better, but I don't know if it's a real problem
- problems with PIXI - I searched GitHub issues and didn't find anything related
Maybe you could advise what this may be related to.