This site requires JavaScript, please enable it in your browser!
Greenfoot back
LewisEro
LewisEro wrote ...

2020/3/26

Add "sluggishness" to enemy projectile tracking???

LewisEro LewisEro

2020/3/26

#
Okay, this one to me seems quite tricky to figure out. So the enemy shoots a projectile at the player, this projectile then follows the player around. That part is easy just by having this function in the act() of the bullet.
    public void aimbot(){

        turnTowards(player.getX(), player.getY()); 
      
    }
now if we add something like 50 to those values, the projectile becomes sluggish. like so :
    public void aimbot(){

        turnTowards(player.getX() + 50, player.getY() + 50); 
      
    }
the problem with this is that it slugs in only one direction. to fix that i think something like this is needed:
    public void aimbot(){
        if(){
        turnTowards(player.getX()+50, player.getY()+50); 
        }
        else{
        turnTowards(player.getX()-50, player.getY()-50);             
        }
    }
the condition for the if will need to determine in which direction the player is moving. is there a way to do this?
LewisEro LewisEro

2020/3/26

#
Perhaps there is another way of doing this by constantly resetting the rotation by a certain amount
Yehuda Yehuda

2020/3/27

#
If you want to make it random you can use the Greenfoot method.
if (Greenfoot.getRandomNumber(2) == 0) {
    // half the time we'll come here (== 0)
} else {
    // the other half will land here (== 1)
}
LewisEro LewisEro

2020/3/27

#
thank you for the suggestion! yeah, considered making it random too. can always resort to that if i cant figure out a way to make it sluggish in a controlled manner ;D
Yehuda Yehuda

2020/3/27

#
LewisEro wrote...
figure out a way to make it sluggish in a controlled manner ;D
I'm not sure what you are trying to do. Explain.
LewisEro LewisEro

2020/3/27

#
Yehuda wrote...
LewisEro wrote...
figure out a way to make it sluggish in a controlled manner ;D
I'm not sure what you are trying to do. Explain.
consider an aimbot in a first-person shooter. if it is good, it will perfectly lock on to players, accounting for movement. this is how the projectiles work currently too. essentially I would like to figure out a way to "soften" the amount of lock on: 0% being the projectile only initially being aimed at the player, 100% being a full-on heat-seeking lock on. a middle ground at 50% would seem perfect for my purposes. the only approach i can think of is checking for player speed/direction and adjusting accordingly by adding/subtracting from the getX() and getY() values.
Yehuda Yehuda

2020/3/27

#
Why is what we have above, not the 50%?
LewisEro LewisEro

2020/3/27

#
it is 50%, but it causes the projectile to shake vigorously.
Yehuda Yehuda

2020/3/27

#
That's because you do it every act cycle. If you make a counter and only change the direction every few act cycles, it won't shake.
LewisEro LewisEro

2020/3/27

#
That approach may word for this application. I think my initial intention in making this thread though was to learn about a method of implementing a sort of "magnetic" or "gravitational" effect, which could be used for multiple purposes.
You need to login to post a reply.