hello i am making a 2 d patformer with combat system. it was hard to understand how it work but over time ı got it . now the skeleton move and reach the player the way as I wanted but it hard to adjust my code is
if (nextWaypointDistance > distance)
{
currentWaypoint++;
}
if ((Vector2.Distance(target.position, rb.transform.position) > 3f) )
{
distanceY = Vector2.Distance(new Vector2(0, rb.position.y), new Vector2(0, path.vectorPath[currentWaypoint].y));
if (path.vectorPath[currentWaypoint ].x==path.vectorPath[currentWaypoint -1].x&& !jumped && path.vectorPath[4 ].x - rb.position.x>-0.3f && path.vectorPath[4].x - rb.position.x < 0.3f)
{
rb.velocity = Vector3.zero;
rb.AddForce(jumpModifier * 40 * Vector2.up, ForceMode2D.Impulse);
jumped = true;
this.Wait(1f, () => {
if (!footE.isGrounded)
{
rb.AddForce(jumpModifier / 3 * 40 * new Vector2(transform.localScale.x, 0), ForceMode2D.Impulse);
};
});
}
}
after speding 2 day and understand how vector works ı actually noticed better idea. ı want to adjust grids follow walkable ways only for ground-based enemies so that when the next vector going up or down npc will decide what to do if is it a stairs or need to high jump or low jump since it currently make high jump but not low jump otherwise jump always because of how vectors finding target. i simply want this vector to always follow the ground instead of going up.
Is there and way to do this ? or can I draw my own grids it would be useful.
actually I can add penalty to everywhere in air so it works but takes too much time. Waiting for answer. thanks in advance
Currently
What I want