• 0

    posted a message on [Advanced] 2D Physics help

    const double FPS = 0.03;
    (first i had 30 as FPS but then i changed it to 0.03 because i don't want to do always 1/FPS)

    Posted in: Galaxy Scripting
  • 0

    posted a message on [Advanced] 2D Physics help

    atm this (because timers makes it buging)

    while (true)
    {
    ball collision
    wall collision
    System.Threading.Thread.Sleep((int)(FPS * 1000)); /*0.03*1000 = time in ms*/
    }

    Posted in: Galaxy Scripting
  • 0

    posted a message on [Advanced] 2D Physics help

    @Twinmold20: Go

    there are no errors but it calculates the time sometimes wrong (i think) :/

    Posted in: Galaxy Scripting
  • 0

    posted a message on [Advanced] 2D Physics help

    ok thanks :)
    (will update the code a bit to make it better to understand)

    Posted in: Galaxy Scripting
  • 0

    posted a message on [Advanced] 2D Physics help

    thats what i do
    get the time of impact then move with speed * time till impact
    but it bugs

    Posted in: Galaxy Scripting
  • 0

    posted a message on [Advanced] 2D Physics help

    the problem is the required time...
    lets say we have 10 balls
    10*10*(int)(speed/20)

    and this / 0.03 sec? :/

    Posted in: Galaxy Scripting
  • 0

    posted a message on [Advanced] 2D Physics help

    i'm working on a simple 2d physics (balls and lines) atm in c#, but if all works fine i transfer it to sc2 so everyone can use it. but i have a big problem.
    the collision detection between 2 balls

    my problem:
    first i used
    move -> for (int j = 1; j <= MaxBalls; j+=1) -> if (dist <= rad1+rad2) move balls outside them and get new vx and vy
    that sucks because they can skip a collision if they have high speed.

    then i found a formula to get the Time Of Impact (like Box2D)
    i implemented it in my sys and it worked fine for a while (as long as they had high speed) but then they hit with lower speed and they got stuck in each other

    so my question is:
    does anyone knows another solution for it or can someone help me to fix the bug?

    formula for Time Of Impact:

    double R = Balls[i].Radius + Balls[j].Radius;
    double a = Balls[i].Vel.X * Balls[i].Vel.X;
    double b = - 2 * Balls[j].Pos.X * Balls[i].Vel.X + 2 * Balls[i].Pos.X * Balls[i].Vel.X;
    double c = - 2 * Balls[i].Pos.X * Balls[j].Pos.X + Balls[i].Pos.X * Balls[i].Pos.X + Balls[j].Pos.X * Balls[j].Pos.X;
    double d = Balls[i].Vel.Y * Balls[i].Vel.Y;
    double e = - 2 * Balls[j].Pos.Y * Balls[i].Vel.Y + 2 * Balls[i].Pos.Y * Balls[i].Vel.Y;
    double f  = - 2 * Balls[i].Pos.Y * Balls[j].Pos.Y + Balls[i].Pos.Y * Balls[i].Pos.Y + Balls[j].Pos.Y * Balls[j].Pos.Y;
    double g = a + d;
    double h = b + e;
    double k = c + f - R * R;
    
    //solve the quadratic equation
    
    double sqRoot = System.Math.Sqrt(h * h - 4 * g * k);
    double t1 = (-h + sqRoot) / (2 * g);
    double t2 = (-h - sqRoot) / (2 * g);
                                    
    if (t1 >= 0 && t1 <= 1)
    {
               whatTime = t1;
               ballsCollided = true;
     }
    if (t2 >= 0 && t2 <= 1)
    {
               if (whatTime == null || t2 < t1)
               {
                          whatTime = t2;
                          ballsCollided = true;
                }
    }
    if (ballsCollided)
    {
                /* run collision between ball i and ball j */
    }
    

    double == fixed in sc2

    and the example: (needs windows and min netframe 3.5)
    use left mouse to push them away and right to drag

    Posted in: Galaxy Scripting
  • 0

    posted a message on Fluid Simulation (So Many Banelings)

    @SouLCarveRR: Go

    collision is on :)

    how do you turn off colision? data editor? if it's done with trigger editor plz say how :D

    btw: nice!!!

    Posted in: Project Workplace
  • 0

    posted a message on Is Wait MUI?

    the same old question...
    if you use only locals and not globals. Yes!

    Posted in: Triggers
  • 0

    posted a message on Diablo 3: which character class do you like?

    i love demon and wizard :D
    PS: http://www.hiveworkshop.com/forums/maps-564/diablo-iii-new-tristram-v-1-01-a-164343/ (Demon Hunter is comming as soon as i finished the spells)

    Posted in: Off-Topic
  • 0

    posted a message on Problem with sliding trigger

    i think it's because (Custom value 0 of Hero[i]) != 1.0
    and if the hero[i] == no unit then it will cause an error
    first make a if Hero[i] != No Unit
    and after if another if with the other conditions

    Posted in: Triggers
  • 0

    posted a message on calling variable functions

    yea i know
    but i want to call a function stored in a variable like
    call VaraiableFunc[i](i,"idk",unit)

    Posted in: Triggers
  • 0

    posted a message on calling variable functions

    is it possible to call a function from a variable? all functions take the same parameters
    i saw something like #PARAM(var) but i don't know how to use it for my problem :/
    in wc3 there was a variable type called code that works like this
    local code func = function BlaBla

    and i also don't want to make 1 function and 10 if's

    some kind of interface

    Posted in: Triggers
  • 0

    posted a message on i broke my mouse D;

    @s3rius: Go

    haha yea try b :)
    always works for me

    Posted in: Off-Topic
  • 0

    posted a message on [Actor] Firebat flames sometimes do not show up

    have the same problem but only 0-2 times
    but i ignore it :)

    Posted in: Data
  • To post a comment, please or register a new account.