Enemy Boss movement AI
Date : March 29 2020, 07:55 AM
Does that help Good day to all, I am trying to get an enemy boss ship to appear on screen and attack my ship and also dodge my attacks sometimes. So far I have gotten him to attack my ship but hes stays on the edge of the screen. Here is my code : , There are many ways to move an object, you can try:
|
Movement of enemy issue
Date : March 29 2020, 07:55 AM
will help you I have a game im making but for some reason the enemy, when it goes down it should start going up but it doesnt. It just starts blinking. Code: , The error is in your upper boundary detection. Change if enemyy >= 10:
if enemyy <= 10:
|
2d platformer enemy movement
Tag : chash , By : Sandip
Date : March 29 2020, 07:55 AM
I hope this helps . I have been researching for at least two hours on how to make an enemy character that moves left and right on a platform without falling off. I have tried out 4 different scripts and gone through 2 youtube tutorials but I just seem to be getting errors on everything. This is my first post so please notify me if i'm doing anything wrong, thank you :). , Here is a very simple solution that can help you get started. using UnityEngine;
using System.Collections;
public class EnemyPatrol : MonoBehaviour
{
Rigidbody2D enemyRigidBody2D;
public int UnitsToMove = 5;
public float EnemySpeed = 500;
public bool _isFacingRight;
private float _startPos;
private float _endPos;
public bool _moveRight = true;
// Use this for initialization
public void Awake()
{
enemyRigidBody2D = GetComponent<Rigidbody2D>();
_startPos = transform.position.x;
_endPos = _startPos + UnitsToMove;
_isFacingRight = transform.localScale.x > 0;
}
// Update is called once per frame
public void Update()
{
if (_moveRight)
{
enemyRigidBody2D.AddForce(Vector2.right * EnemySpeed * Time.deltaTime);
if (!_isFacingRight)
Flip();
}
if (enemyRigidBody2D.position.x >= _endPos)
_moveRight = false;
if (!_moveRight)
{
enemyRigidBody2D.AddForce(-Vector2.right * EnemySpeed * Time.deltaTime);
if (_isFacingRight)
Flip();
}
if (enemyRigidBody2D.position.x <= _startPos)
_moveRight = true;
}
public void Flip()
{
transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
_isFacingRight = transform.localScale.x > 0;
}
}
|
Pygame Simple Movement: Enemy mimicking player movement and also retracing steps
Date : March 29 2020, 07:55 AM
help you fix your problem A solution would be the putting a list as an attribute to your pac-man class. For example, self.steps=[]. The pac-man would list his coordinates so that the ghosts could track him. Implemented into your code: class PacMan(pygame.sprite.Sprite):
def __init__(self, x, y, radius):
super().__init__()
self.image = pygame.Surface([radius, radius])
self.image.fill([250, 250, 0])
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.queue = [-speed1, 0]
self.direction = [-speed1, 0]
#add some starting values
self.steps=[]
def update_steps():
#add current position
self.steps.insert(0,(self.rect.x,self.rect.y))
#delete old steps
del self.steps[:-1]
def update_pos(steps):
self.rect.x=steps[:-1[1]]
self.rect.y=steps[:-1[2]]
|
Different Movement of The Enemy
Date : March 29 2020, 07:55 AM
hope this fix your issue , everyone for the help. I figured out how to keep my enemy moving infinitely in the manner I wanted. let move1 = SKAction.moveToY(CGPoint: size.width * //int)
let move2 = SKAction.moveToY(CGPoint: size.width * //int)
let sequence = SKAction.sequence([move1, move2])
let repeat = SKAction.repeatForever(sequence)
//enemy.run(repeat)
|