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

Making Straight Particle

Discussion in 'Development' started by Hoyee, Mar 4, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    Using cos, sin, and for, make 10 particles in a straight line in the direction that the player looks at. Because I want some code example.
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    you could do something like
    PHP:
    for($i=0;$i 10;$i++)
    $level->addParticle(new PARTICLE($player->add(0,1.62)->add($player->getDirectionVector()->multiply($i))));//PARTICLE is whatever particle class you want to use
     
  3. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Try devise some code by yourself for that. It isn't that hard to do it as it seems... You won't take anything from it if I put the finished code here.
     
  4. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    I tried many times but I don't quite understand it yet about using sin cos.
     
  5. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    can't make with using sin cos ? plz
     
  6. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    I'm not sure this will work, if don't try add PI/2 or 3PI/2 in function's arguments

    PHP:
    $lenght 20;
    for(
    $i 0$i $lenght$i++) {
       
    $x $i cos(deg2rad($player->getYaw()));
       
    $z $i sin(deg2rad($player->getYaw()));
       
    $y $player->getY() + 1;
    }
     
  7. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    just getYaw() is left, isn't it? or is getYaw() get's player's looking side? I can't try code now so can you tell me
     
  8. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    it's code for direction with const Y
     
  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.