[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 156 KB, 500x355, 1679122741319981.gif [View same] [iqdb] [saucenao] [google]
15469077 No.15469077 [Reply] [Original]

hello /sci/,
I didn't want to make a stackoverflow account or get bullied there, so I decided I'd ask my programming question here. Basically I'm trying to have archers aim towards a random point within a small area around a cursor. However just having them aim towards the most recently generated random point would cause their aiming motions to be jerky, so I thought I would have their aim continuously move towards the newest randomly generated point, but this means they just aim vaguely towards the center of the area because the random values trend towards cancelling outward movement out, even if I weight the random number towards the outside. So basically what I'm trying to do is weigh the new RNG number to be closer to the previous RNG value; so it has a sorta of continuous flow around the random area.

Do you know a good way to do this in c#? (I'm doing this in Unity).

>> No.15469088

Use lerping

>> No.15469094

>>15469088
I'm basically already doing that; but the problem is I'm continuously moving towards a new RNG number in an area (because the area of aim is constantly expanding or constricting based on your mouse movement, think CSGO reticle) so even when I use lerping it's constantly moving in a small area around the minimum of the random range because of how the probabilities work.

>> No.15469123

>>15469077
you sure do seem to like talking about yourself on social media

>> No.15469143
File: 946 KB, 500x355, 1591417626810.gif [View same] [iqdb] [saucenao] [google]
15469143

>>15469123
pls no bulli

>> No.15469175

>>15469077
just doa randomized muzzle velocity thing
the muzzle will have some verticle velocity, and horizontal velocity.
set a cap to the velocity
then each loop, just add 1 or -1 to the muzzle velocity.

>> No.15469199

after reflection and help from anon on /g/, I think i'll try to have a function that is moving the archer's aim towards the target random position(which will be unchanging until it is reached) and it will also check if it is out of the current random range and if it is it will generate a new random target position and start moving towards that. I think that will achieve my goal the simplest way