Legacy GM Move object over the water

P

potasiopotaq

Guest
ENGLISH:
Good afternoon everyone! :cool:

My question is:
I have an shark object (obj_shark) and I want make it move only when it's above the water object (obj_water).
That is, I have a lot of water objects in the room, located next to each other that make up a lake, and the shark should only move over those objects, without going outside.

The movement of the shark is 360 degrees (like TDS). My problem is that I don't know how to detect that there are no more obj_water in the way of the obj_shark, and this does not change its trajectory.

Finally I want to clarify that there are many lakes, with sharks inside, so I can't delimit the edges manually with a solid object. The obj_tiburon must automatically detect that it can't continue in this direction.

Thank you very much, I hope some answer. Greetings to the community!
PD: sorry for my poor english. :rolleyes:


ESPAÑOL:
Buena tardes para todos!

Mi consulta es la siguiente:
Tengo un objeto tiburon (obj_tiburon), y quiero hacer que este solo se mueva cuando este encima de un objeto agua(obj_agua). Es decir, tengo un monton de objetos agua en la room, ubicados uno al lado del otro que conforman un lago, y el tiburon solo debe moverse por encima de esos objetos, sin salirse afuera.

El movimiento del tiburon es de 360 grados (estilo TDS). Mi problema se halla en que no se como detectar que no hay mas obj_aguaen el camino del obj_tiburon y este no cambia su trayectoria.

Por ultimo quiero aclarar que hay muchos lagos, con tiburones dentro, por lo que no puedo delimitar los bordes manualmente con un objeto solido. El obj_tiburon debe detectar automaticamente que no puede seguir en dicha direccion.

Muchisimas gracias, espero alguna respuesta. Saludos a la comunidad!
 

TheouAegis

Member
Do you know how to do a normal collisions? Then just do the reverse. Rather than checking for Collision check if there is no Collision.
 
B

Badger

Guest
Are you using built-in variables?
If so, then maybe something like this would help:
Code:
if(!position_meeting(x+lengthdir_x(speed,direction),y+lengthdir_y(speed,direction),oWater)){
 direction+=180;
}
It is not the best solution, but it should work. If you are not using built-in variables, then you should post some code so that people know what is going on.
 
Top