0 votes

So here's what im trying to do, I'm trying to implement a parry mechanic to my fps game basically its like a baseball bat, when the player swing the bar at the right moment any projectile coming at them will go back to where the crosshair is at kinda like the parry mechanic in ULTRAKILL if you know it.
Now im not expecting anyone to give me how to exactly do it i just want the logic on how to do it as well as what nodes will help plus what difficulty i might face

Godot version 3.4.0
in Engine by (57 points)

1 Answer

0 votes

I think the simplest way would be to code weapon swing in a way it will extend some hitbox collision shape in fixed position in front of your player for a fixed short time, and after that time reset shape scale to 0. Collision with this hitbox will reverse direction of projectile, no if condition needed. Bat swing can be only animation, no need for using bodies or areas for it.

by (7,447 points)
Can you explain a bit more?

What I mean is :
Baseball bat swing is an animation. It makes your character look like it swings the bat in front of him. Bat will not be real object, will have no body, no collision shape - it will only be mesh and animation.
Your character will have an Area called ParryBox as a child. It will be positioned in some small distance in front of your character. Its collision shape will be a box. Box max extents will reach something like Vector3(10,15,1) - so its Z axis is very thin.
ParryBox masks colliisons only with projectiles
Parrybox code is : on body entered -> reverse this body velocity/ or trigger this body parried function.
When no button is pressed ParryBox will remain disabled or its sollision shape shrinked to 0.
Pressing the button will trigger bat swing animation as well as enabling ParryBox/ enlarging it to max extents. After short time ( or on animation ended/ on animation progressed) ParryBox shrinks/disables again.

This will basically create a thin wall for a very short time that will catch projectiles if clicking the button is correctly timed. It will also require good basic state_machine for your character, to not allow him to endlessly click parry or hold it down.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.