Hello everybody, probably the heading for this thread sounds strange but I Really have troubles when dealing with function object_get_parent and object_index variable, so what I want to achieve is simply make one object perform the action depending on what it collided with, so For Example, if the enemy object collides with player object it will decrease the hp of player. So to realize it I have parent object for player, called pobj_hero, so the player is instance of object called obj_hero_druid which parent is pobj_hero. Next, I have Collision Checking script that returns the instance_id of the object you collide with, and lastly I have step event for enemy object:
So, the problem is in the first 2 lines of the code, I discovered it by using debug mode, and it didn't stop on the stop point(marked in code) inside "if" statement.
Also having just pobj_hero instead of pobj_hero.object_index doesn't work too. So I am really stunned, why doesn't it work if the Manual seems to say that object_get_parent returns unique object_index?
Still it could be my fault somewhere else but I just want to know how to realize such things properly and how this stuff rowks because it ain't the first time I am having problems here with. Help please.
GML:
#region//Movement
var collided_with = EntityMovement();//Script returns instance_id
if(object_get_parent(collided_with)=pobj_hero.object_index)//Having just pobj_hero
//Doesn't work too
{
// *** Stop Point for Debugging
with(collided_with)
{
movement_direction = 0;
state = state_pushed;
pushed_speed = other.pushing_speed;
pushed_direction = radtodeg(arccos(cos(degtorad(other.pushing_direction) * other.movement_direction )))
Vx = lengthdir_x(pushed_speed,pushed_direction);;
Vy = lengthdir_y(pushed_speed,pushed_direction);;
x += Vx
y += Vy
RecieveDamage(1);
}
}
Also having just pobj_hero instead of pobj_hero.object_index doesn't work too. So I am really stunned, why doesn't it work if the Manual seems to say that object_get_parent returns unique object_index?
Still it could be my fault somewhere else but I just want to know how to realize such things properly and how this stuff rowks because it ain't the first time I am having problems here with. Help please.