Skocz do zawartości

Zablokowane najbliższy object


Rekomendowane odpowiedzi

Opublikowano

mam wroga [obj enemy] i mam object za ktorym on chodzi [obj badstop ma zaznaczony path] w wiekszych ilosciach badstopow i tak idzie do jednego i tego samego . jak zrobić żeby obj enemy szedl do najbliższego obj badstopa a nie obojetne ktory

Opublikowano

Step:

if (instance_exists(obj_badstop)
    {
direction=point_direction(x,y,instance_nearest(x,y,obj_badstop).x,instance_nearest(x,y,obj_badstop).y);
    }

  • Administratorzy
Opublikowano
Step:

if (instance_exists(obj_badstop)
    {
direction=point_direction(x,y,instance_nearest(x,y,obj_badstop).x,instance_nearest(x,y,obj_badstop).y);
    }

 

 

a nie lepiej:

if (instance_exists(obj_badstop)
    {
    var near;
    near=instance_nearest(x,y,obj_badstop);
    direction=point_direction(x,y,near.x,near.y);
    speed=1; //ewentualnie, jak nie ma gdzie indziej
    }

Opublikowano

A najlepiej będzie tak :P

if (instance_exists(obj_badstop))
    {
    var near;
    near=instance_nearest(x,y,obj_badstop);
    direction=point_direction(x,y,near.x,near.y);
    speed=1; //ewentualnie, jak nie ma gdzie indziej
    }

Opublikowano

właściwie to błąd jest dziwny, bo nawet po usunięciu kodu od was błąd dalej występuje... sorry ale ostatnie nie mam czasu do komputera..

błąd polega na

 

unknown variable x albo jak są bloki {} to pisze ze else mu przeszkadza

pbphii

a tu całe draw: a może cały objeckt, jest mi juz wszystko jedno.....:

 

Create Event:
set variable badstop_going to 1
set variable going to 0
set variable hp to 20
set variable attack to 5
set variable attack_speed to 35
set variable can_attack to 1
set variable spr_change to 0

Alarm Event for alarm 0:
set variable can_attack to 1

Step Event:
execute code:

if (instance_exists(obj_badstop))
    {
    badstop_going=1
    direction=point_direction(x,y,instance_nearest(x,y,obj_badstop).x,instance_nearest(x,y,obj_badstop).y);
    move_towards_point(instance_nearest(x,y,obj_badstop).x,instance_nearest(x,y,obj_badstop).y,3)
    }

execute code:

if (distance_to_object(hands)<200)
{
going=1
move_towards_point(hands.x,hands.y,5)
}

if hp is not equal to 20
      start moving in the direction of position (hands.x,hands.y) with speed 5
if at relative position (0,0) there is object hands
      set variable spr_change to 1
      start moving in the direction of position (hands.x,hands.y) with speed 0
      if expression true is true
            if can_attack is equal to 1
                  set variable global.hp relative to -attack
                  set variable can_attack to 0
                  set Alarm 0 to attack_speed
if hp is smaller than 0
      destroy the instance
if hp is equal to 0
      destroy the instance

Collision Event with object blocker:
bounce not precisely against solid objects

Collision Event with object obj_arrow00:
for other object: destroy the instance
set variable hp relative to -4
set variable going to 1
start moving in the direction of position (hands.x,hands.y) with speed 5

Collision Event with object obj_arrow01:
for other object: destroy the instance
set variable hp relative to -8
set variable going to 1
start moving in the direction of position (hands.x,hands.y) with speed 5

Draw Event:
at relative position (-5,-70) draw the value of: hp
execute code:

if going = 1
{
if spr_change = 1
draw_sprite_ext(enemy01a,image_index,x,y,1,1,point_direction(x,y,hands.x,hands.y),c_white,1)

else

draw_sprite_ext(enemy01,image_index,x,y,1,1,point_direction(x,y,hands.x,hands.y),c_white,1)
}
if badstop_going is equal to 1
      execute code:

if going = 0
draw_sprite_ext(enemy01,image_index,x,y,1,1,point_direction(x,y,obj_badstop.x,obj_badstop.y),c_white,1)

  • Administratorzy
Opublikowano

w błędzie pisze w ktorej linijce występuje błąd, sprawdź ją. Jezeli pisze unknown variable x, to na bank nie istnieje jakiś obiekt do którego x się odwołujesz (przynajmniej w momencie odwołania).

Opublikowano

Jest!!!!!!!!!!!!!!!!!!!!!!! <hura>!!!!

okazało sie ze w roomie[lubie to słowo, ekhm] byl nie obj badstop, tylko obj arrstoper........ maja ten sam sprite, wiec dodajac do rooma nie wiedziałem ze dalem nie ten co chcialem, dzieki za przypomnienie dlaczego blad wystepuje, dzieki!!!!

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...