HelpHit Packets

Posts 1–6 of 6 · Page 1 of 1
Hit Packets
Hey. i want to simulate client's work. And I need to find out how to work with playerhit, enemyhit, otherhit packets.
Now iam trying to predict player's projectile collision.

Hooked for playershoot and enemyhit packets. Mapping playershoot's time, location, angle, spd. When enemyhit happens, i compare enemy's position and predicted projectile position.

Code:
public Location PredictLocation(Location StartLoc, int spd, int starttime, float angle, int newtime)
        {
            float speed = (spd / 10f) * ((newtime - starttime) / 1000f);

            Location ResultLoc = new Location();
            ResultLoc.X = StartLoc.X + (float)Math.Cos(angle) * speed;
            ResultLoc.Y = StartLoc.Y + (float)Math.Sin(angle) * speed;
            return ResultLoc;
        }
StartLoc - position in playershoot packet.
spd - projectile spd. I tested it on knight with sword, which spd is 100.
starttime - time in playershoot packet.
angle - angle from playershoot packet converted to normal angle (0-360).
newtime - time in enemyhit packet.

And this code can predict in close range. But the longer the distance, the greater the error. As I know, projectile hit, when its come closer than 0.5 unit. When I test it in 1 tile range, projectile predicted position was closer than 0.5, but when I shoot from ~3 tiles range, predicted position was further than 3.0.

Can someone tell me, where I made mistake?
Quote Originally Posted by ruusey View Post
I think your maths are a little off. Found a great article on stack exchange looks like hes doing something very similar. Look at answer #2
https://stackoverflow.com/questions/...ojectile-and-uⓘ
Thank you for link. Its will be very useful for me.
If someone interested, the problem was in angle. I need to use angle as radian not as degrees.
What is the difference between using in radians and degrees? They can both be converted to make them equal?
Quote Originally Posted by Anime View Post
What is the difference between using in radians and degrees? They can both be converted to make them equal?
Math.Sin and Math.Cos using radians.
Quote Originally Posted by Urantij View Post
Math.Sin and Math.Cos using radians.
Do you have Skype where we can talk?
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?