1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Getting negative values

Discussion in 'Development' started by CupidonSauce173, Feb 23, 2018.

  1. CupidonSauce173

    CupidonSauce173 Zombie

    Messages:
    298
    GitHub:
    cupidonsauce173
    Hi, I know this is stupid but I can't figure it out, how do I put these values to be negative ? to make the player to be launch in -z direction and not +z direction.
    PHP:
                if($block != && in_array($block$this->blocks)){

                    if(!isset(
    $this->bounceVelocity[$player]) || $this->bounceVelocity[$player] == -0.0){
                        
    $this->bounceVelocity[$player] = ($player->getMotion()->getZ() + 0.2);
                    }

                    if(
    $this->bounceVelocity[$player] <= $this->max){
                        
    $this->bounceVelocity[$player] = ($this->bounceVelocity[$player] + 0.2);
                    }

                    
    $this->fall->attach($player);
                    
    $motion = new Vector3($player->motionX$player->motionY$player->motionZ);
                    
    $motion->$this->bounceVelocity[$player];
                    
    $player->setMotion($motion);
                }

                if(isset(
    $this->fall[$player])){

                    if(!
    $block == && !in_array($block$this->blocks)){
                        
    $this->fall->detach($player);
                        
    $this->bounceVelocity[$player] = 0.0;
                        
    $player->setMotion(new Vector3(0.00.00.0));
                    }
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Multiply the coordinates -1.
     
  3. CupidonSauce173

    CupidonSauce173 Zombie

    Messages:
    298
    GitHub:
    cupidonsauce173
    $player->setMotion(new Vector3(0.0, 0.0, 0.0));
    this line ?
    @GamakCZ
     
    Last edited: Feb 23, 2018
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
                 if($block != && in_array($block$this->blocks)){

                    if(!isset(
    $this->bounceVelocity[$player]) || $this->bounceVelocity[$player] == -0.0){
                        
    $this->bounceVelocity[$player] = ($player->getMotion()->getZ() - 0.2);
                    }

                    if(
    $this->bounceVelocity[$player] <= $this->max){
                        
    $this->bounceVelocity[$player] = ($this->bounceVelocity[$player] - 0.2);
                    }

                    
    $this->fall->attach($player);
                    
    $motion = new Vector3($player->motionX$player->motionY$player->motionZ);
                    
    $motion->$this->bounceVelocity[$player];
                    
    $player->setMotion($motion);
                }

                if(isset(
    $this->fall[$player])){

                    if(!
    $block == && !in_array($block$this->blocks)){
                        
    $this->fall->detach($player);
                        
    $this->bounceVelocity[$player] = 0.0;
                        
    $player->setMotion(new Vector3(0.00.00.0));
                    } 
    LOL, put this on facepalm :facepalm:
     
  5. CupidonSauce173

    CupidonSauce173 Zombie

    Messages:
    298
    GitHub:
    cupidonsauce173
    ah, thank you
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.