(I need extreme help or bad things will happen with me) How do I create a game like Deepest Sword?

I have a little more than 7 days to finish the beta of a game for a school project where everyone is counting on me, but I’m stuck, the game is totally based on Deepest Sword, and I need to exactly replicate the physics of this game, but I’m encountering a lot of problems:
1- The sword box collider goes through walls
2- Spinning the sword does not move the character forward
Not only that, but I only managed to create the character and make the sword spin, I can’t go beyond that, and I need to replicate the physics of this game quickly or I will disappoint all my teachers and my classmates, please help me.
I’m new at game making, so I need a LOT of help, please.
I will attach a gameplay of Deepest Sword that show exactly all the physics:

1 Like

So problem 1 and 2 seem to be related, the box collider goes through walls because it cant move the character wielding the sword. I have not played the game, but I guess you can’t jump and have to use the sword to climb and get around. Could you maybe post some code of how you are currently doing things?

The way I would set this up, just looking at the video would be to give the character a 2d rigidbody and the sword is under the character/a child of it in the hierarchy that also uses a rigidbody 2d.

Give the sword a capsule collider 2d which will make collision smooth. You can also easily change its length that way, as you can modify the size of the collider. Also, I would increase the swords mass value every time it grows.

The most important part though is: Use a joint for example a hinge joint 2d on the sword. Then set the Connected Rigidbody value to the character rigidbody.
From script, you can enable the useMotor value if you want the sword to move and disable it again. You can set the motor torque and speed values to positive or negative values to have it rotate left and right.

To make everything smoother to move and look at, enable rigidbody interpolation and make collision detection continuous. Also I am not sure, but maybe make the players collider a sphere collider to have it pass through corners more easily, also lock its rotation if you have not already done that.

I hope this helps, dont worry about disappointing anyone, you got this!
And even if it doesn’t work perfectly at the end, this is quite a challenging system for someone just starting out even if it might seem simple.

1 Like

Thank you very much, you helped me a LOT!
But now I just encountered another wall, how do I control the hinge joint motor with the arrow keys? I imagine it’s something like the character’s movement, making the motor at the hinge joint go to 1 or -1 and multiplying by the Motor Speed.
But I didn’t find anything explaining how to program this

Youre welcome! So in pseudo-code I would do:
float direction = 0; //This will stay 0 if no button is pressed
if(button to the left is held down)
direction = -1;
else if(button to the right is held down (Input.GetKey))
direction = 1;

if(direction == 0) //Not pressing a button
joint.useMotor = false;
else
{
JointMotor2D motor = joint.motor;
motor.motorSpeed = direction; //Direction might be too little, maybe instead of -1 and 1 use a much higher number to push the player upwards more
joint.motor = motor;
//Need to reassign it, if youre a beginner this might be confusing, usually you would have been able to access motor.motorSpeed directly with joint.motor.motorSpeed but the way its setup in the background requires this with some Unity functions sometimes
}

I hope this helps, I have not tested this but thats what I would try

1 Like

I quickly implemented a working prototype because I really liked the gameplay. It also contains the control script for the motor that you were asking for.

@Vincent13122 already gave you a good starting point by hinting to HingeJoint2d and you even knew about the hinge joint motor. But I don’t believe you didn’t find anything on how you program this. Plenty of tutorials on how to read player input and plenty of tutorials using HingeJoint2D. Please don’t be lazy.

Google search “hingejoint2d motor”:
https://www.youtube.com/watch?v=l6awvCT29yU

1 Like

sorry, forgot to attach the file. Create a new 2D unity project and import this file. The scene is called “Scenes/Test Scene”

8234856–1076385–sword.unitypackage (5.14 KB)

1 Like