Results 1 to 4 of 4

Thread: [AI movement] Jumping using movegravity()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts

    [AI movement] Jumping using movegravity()

    PHP Code:
    jump(startend)
    {
        
    height end[2] - start[2];
        
    v0 275;
        
    t0 v0 getcvarint("g_gravity");
        
    s0 0.5 getcvarint("g_gravity") * t0 t0;
        
    height -= s0;
        if(
    height 0)
            return 
    false//no jumping possible. Target too high.
        
    t1sq = -height getcvarint("g_gravity");
        
    time int((sqrt(t1sq) + t0) * 20) / 20;
        
    xdist end[0] - start[0];
        
    ydist end[1] - start[1];
        
    xspeed xdist time;
        
    yspeed ydist time;
        
    self movegravity((xspeedyspeedv0), time);
        
    wait time;
        
    self.origin end;
        return 
    true;

    Just some math...
    To change this function into fall(), just set v0 to 0, t0 to 0 or s0 to 0. (or remove all associated stuff)

  2. The Following 3 Users Say Thank You to IzNoGoD For This Useful Post:

    Jeplaa (18th May 2013),kung foo man (18th May 2013),Ni3ls (18th May 2013)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •