Jump to content


Photo

Problem with reffering to variables of "other"


  • Please log in to reply
2 replies to this topic

#1 Whalesnail

Whalesnail

    GMC Member

  • New Member
  • 9 posts

Posted 27 May 2012 - 09:49 AM

So, I read somewhere that "other" in a collision event refers to the other object involved in the collision, specifically the INSTANCE of the other object involved.

I simply cannot get this to work right. I need an object to act according to the image_angle of the object it is colliding with. My code looks something like this:
if collision_point(x,y,obj_example,true,true)
    {
        hspeed+=lengthdir_x(1,other.image_angle)
        vspeed+=lengthdir_y(1,other.image_angle)
    }

But other.image_angle just seems to keep spitting out a value of 0.

What am I doing wrong?
  • 0

#2 Jack Indie Box

Jack Indie Box

    GMC Member

  • GMC Member
  • 1460 posts
  • Version:GM:Studio

Posted 27 May 2012 - 10:01 AM

that isnt a "collision event", you would need to use

with(collision_point(x,y,obj_example,true,true)){
hspeed+=lengthdir_x(1,other.image_angle)
vspeed+=lengthdir_y(1,other.image_angle)
}

//i may be wrong but i read that with statements without a valid object(ie. the collision point doesnt collide) will not run and wont error, so i didnt put obj=collision_point(x,y,obj_example,true,true); and if(obj){with.......}

collision events in there self are the built in ones that happen precisely between 2 objects
  • 1

#3 Blake

Blake

    GMC Member

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 27 May 2012 - 01:08 PM

Accidental post, my apologies.

Edited by Blake, 27 May 2012 - 01:09 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users