mikeee324 / OpenPutt

Golf System for VRChat Worlds
MIT License
13 stars 3 forks source link

Ball hit direction not always very accurate #56

Open mikeee324 opened 4 months ago

mikeee324 commented 4 months ago

The direction that the ball is sent after being hit can be wrong for some people. So if a person tries to hit the ball forwards, sometimes it might go left/right a lot more than you'd expect it to.

Usually happens more for people who are trying to hit the ball while sat down. Must be something to do with the angle of the club head in relation to the ball but it's a hard thing to replicate reliably.

I've tried a few different ways of working this out, but there's probably something I'm missing currently.

mikeee324 commented 3 months ago

Not sure where your message went on here @desick but I'll respond anyway 😅

The colliders are a bit larger on purpose just to give a bigger area to help reduce misses when the club head is slightly below or above the ball. I noticed a lot of people were quite frustrated with it when I the collider sized exactly to the size of the club head.

I don't think changing the size of the collider should affect the direction that much though as it's just tracking the center point on the club head.

At some point soon I might have another go at trying to track down what's going on. Need a way of replicating a "bad" hit first though.

Also, if you see this let me know when you release your map or start testing it with people! I'd love to see it!

desick commented 3 months ago

My apologies, I really was hoping my comment would've vanished before you could read it, since after my comment I went digging/testing further as well into the code and felt that my thought process wasn't complete. Though, I was referring to the actual size of the club off of the face, rather than the height of it, since I've noticed the same thing, people leaning into their swings or pulling away from the ball.

Leading into another thought process, do you think that it may be related to the motion of the swing? Since in a 3D space when one swings a club, there is really three dimensions of movement, the forward movement (lets say x axis), the side to side as people swing their shot (z axis), and the club coming down (y axis). I'm not sure how exactly unity and this code calculates the transference of forces, but if after the impact it transfers that last vector of movement, could it be forcing it to stray left/right? I know the code limits/stops vertical shots (y axis) so in normal play we don't see chip shots, but if we're swinging the club at a 90 degree angle lets say, would that be affecting the shot? Since now, the "z axis" is the now acting as the portion of the downswing and instead of "chipping" the shots, we're getting a bit of ball stray? I believe if i understand it, there is some smoothing and averaging occurring, but with how some people putt, they may be swinging more like a driver and less like a putter and the smoothing is grabbing portion of the forces from the earlier part of the swing. Of course, this really only covers my thought process for balls hooking hard. For slicing, it would lead me back to a collider/poor swing issue.

I think to test, one could try setting up some animations in unity where it just simulates some common swings from people at different angles. If its what i said above, it should be repeatable. I tried something up myself, but I'm not very good with Udonsharp to get something going.

The map is currently in community labs, its the "Monty Golf". Be warned, its in early stages of texturing/lighting. and the the holes are just from the game its pulled from so they're not very high quality, but are "functional" (who knew horror game devs wouldn't spend hours on perfecting a course design for VRChat?) Also, if you wanted to add me on Discord, my username is the same as Github.

mikeee324 commented 3 months ago

Ah don't worry! I was just a bit confused as I read the email from github then wondered what happened to it when I clicked through.

It definitely needs a proper look into when I feel like actually getting into. First step will be trying a way to reliably replicate bad hits using some real data from the game. Then after it'll be figuring out what exactly is happening. Might be a little while before I get around to it though. Spending a bit more time on random little projects for a while right now.

I'll go have a look at your monty golf thing this weekend probably :) I'm interested in anything that's using OpenPutt because it means more VR mini golf to play! I'll send you a request on discord in a bit also!