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

Coords Between 2 coords

Discussion in 'Development' started by UnknowG, Apr 25, 2021.

  1. UnknowG

    UnknowG Creeper

    Messages:
    1
    GitHub:
    Steellgold
    Hello

    How foreach coords between 2 coordinates pocketmine
    I would like to make particles appear between 2 coordinates
     
  2. Axon

    Axon Zombie

    Messages:
    276
    Here is the ForEach documentation: https://www.php.net/manual/en/control-structures.foreach.php
    Particles Code:
    PHP:
    $level $this->getServer()->getLevelByName("newhub");
    $pos = new Vector3(000);
    $count 1;
    $particle = new HeartParticle($pos0);
    $random = new Random((int) (microtime(true) * 1000) + mt_rand());
    for(
    $i 0$i $count; ++$i){
        
    $particle->setComponents($pos->x$pos->y$pos->z);
        
    $level->addParticle($particle);
    }
    Good luck!
     
    Agent likes this.
  3. Primus

    Primus Zombie Pigman

    Messages:
    749
    PHP:
    $posA$posB;

    $particleInterval 0.1;
    $dir $posA->subtract($posB)->normalize();
    $dist $posA->distance($posB);
    $particleCount floor($dist $particleInterval);
    $particle = new HeartParticle($posA);

    for(
    $i 0$i $particleCount$i++) {
        
    $particle->setComponents($posA->$dir->* ($particleInterval $i), $posA->$dir->* ($particleInterval $i), $posA->$dir->* ($particleInterval $i));
    }
    Probably won't work. But oh well, it's better than nothing.
     
  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.