Im wondering if mouse related swings with melee weapons is possible in roblox.
Here’s what I’m talking about: Warning: This video contains gore https://youtu.be/p-B4AwgArwA
(1:30 is where the topic I’m talking about is)
How would I be able to replicate this in roblox, if it’s even possible.
Yes it is possible, I’d start by finding the beginning and ending point of the swing on the screen, then I would try to determine whether it is an attacking move or a defense. Now you can find the corresponding points in the 3D space to these beginning and ending points and perform a sword attack or defence if you have implemented some sort of system that detects if two players are fighting together and their swords should collide.
It’s certainly possible to do, but I feel like it would be greatly restricted by player ping - In general, I’ve observed that the latency to Roblox servers can be really high and fluctuate alot. You would probably need slower animations to give time for client-server communication, and making blocking feel responsive would probably be tricky.
This is most definitely possible on Roblox. The movement can be accomplished with procedural animation that utilizes inverse kinematics for both arms. For the arms to be fluid like that, look into mesh deformation. The swings and natural movement can be accomplished a variety of ways. One being an upper-level math & physics (calculate momentum to displace the arms) approach. The rest is merely creating assets to fit with the game’s preferred or chosen design.
This would work best in VR but, if you were to do it in first person, it would work fine.
Inverse Kinematics is a term that’s derived from Robotics. It’s the concept of where segments can be calculated to produce a certain distance & angle to reach a goal. There’s a multitude of ways to accomplish this but, triangles seem to be the most common method. The best example I can think of on the top of my head would be your arm. Your shoulder is your starting position. Your shoulder to your elbow would be segmented as is the elbow to your hand. When you go to grab something, you’ll notice that your arm makes a certain angle and rotation to reach that object.
Tradelands uses a system exactly like this, not as polished but yes it’s possible
EDIT: Users above have suggested some overly complex methods to approach this such as IK which I think is not needed at all
I would approach this by finding the change in the camera’s angle (as opposed to doing anything with the mouse beside grabbing input) and what direction this change occurred this is where trig would come in but I’m only covering the basic idea of this concept so no trig this time xd
I’d then store that angle and direction depending on the magnitude of the change, if the magnitude is great that means the player wants to perform a swing. these values reset after a second or two meaning a player has a second or two seconds to click allowing them to perform that certain swing/attack within the timespan of moving their camera about.
the rest is just playing animations for the different directions.
honestly this is more straightforward and could be easily accomplished without the need for inverse kinematics or a procedural animation system(which would take more time to make).
please if anyone has a better method/way to go about this or sees a flaw in my concept let me know because I might try this in the future.
I don’t believe you need inverse kinematics for this and only a basic procedural layer.
What you’ll want to do is have pre-recorded animations done along a straight line, and then adjust waist transform based on a min and max range(I just use camera angle Y for this)
This will make your attacks “follow” your camera.
Very basic idea
local waistAngle = PercentBetween(currentCameraAngleX,cameraXMin,cameraXMax) -- Returns 0-1 float to be used for the waist
-- Animation transform step
local waistBendGoal = waistAngle -- just waist angle for this example, in my game this is a replicated and compressed + decompressed value
local waistAngleGoal = Lerp(minWaistAngle,maxWaistAngle,waistBendGoal); -- May need to do 1-goal , depending on how you have your camera stuff set up
local alpha = math.clamp(deltaTime/WaistInterpolationTime,0,1); -- interpolation alpha
self.waistAngle = Lerp(self.waistAngle,waistAngleGoal,alpha);
Waist.Transform = CFrame.Angles(math.rad(self.waistAngle),0,0) * Waist.Transform;
For first person, I typically just smoothly transition from my first person view model to the real world model whilst attacking, then interpolate the view model back to where it’s supposed to be once the end of the animation is triggered.