Jump to content


Photo

Object always on another object


  • Please log in to reply
7 replies to this topic

#1 _189812

_189812

    GMC Member

  • New Member
  • 1 posts

Posted 20 February 2011 - 02:21 PM

so im making this game where i need this little circle to always follow and be on the player 1 object. the little circle is called p1hitbox
if a bullet hits the little circle the player will explode(you do not need to help me with this).
i have tried "move towards object" in both gml and drag and drop.
the gml code on the step event is


if distance_to_point(p1.x + 4, p1.y + 16) = 0
speed = 0
else
move_towards_point(p1.x +4, p1.y + 16, 7)

the code im currently using doesnt work, some times when it stops it starts vibrating and some times it doesnt stop in the middle of my p1 object.....


i just want the object to be right in the middle of my p1 object.
middle is
x + 4
y + 16
when the p1hitbox(the little circle) reaches the middle (x + 4, y + 16) it will stop, but when the player moves again it will move to the middle.
in other words.. the little circle(p1hitbox) should ALWAYS be in the middle of the object.
ive searched for hours and tried various things but i cant seem to get it working......


pls help i really appreciate it
  • 0

#2 Dark Matter

Dark Matter

    RPG Expert

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

Posted 20 February 2011 - 02:31 PM

Do:
x=p1.x+4;
y=p1.y+16;
in the step event of the object.
  • 0

#3 Rtyp06

Rtyp06

    GMC Member

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

Posted 20 February 2011 - 02:52 PM

Do:

x=p1.x+4;
y=p1.y+16;
in the step event of the object.


Put it in the draw event so it doesn't lag.
  • 0

#4 Dark Matter

Dark Matter

    RPG Expert

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

Posted 20 February 2011 - 02:55 PM

It won't lag in the step event any more than the draw event (which is not at all)...
  • 0

#5 mr.muffin96

mr.muffin96

    GMC Member

  • New Member
  • 247 posts

Posted 20 February 2011 - 03:50 PM

The end step event has much less lag than the regular step event I've found. I would use that.
  • 0

#6 Dark Matter

Dark Matter

    RPG Expert

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

Posted 20 February 2011 - 04:04 PM

They both have the same amount. Saying they're different is stupid - they do the same thing, at different times.
  • 0

#7 mr.muffin96

mr.muffin96

    GMC Member

  • New Member
  • 247 posts

Posted 20 February 2011 - 05:43 PM

They both have the same amount. Saying they're different is stupid - they do the same thing, at different times.


I agree. I think you're misunderstanding us when we say lag. We mean there is a delay between when the "leader" object moves and when the "following" object follows. Try it yourself, make 2 objects and have one snap to the mouse in the end step event and the other in the step event.
  • 0

#8 Dark Matter

Dark Matter

    RPG Expert

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

Posted 20 February 2011 - 05:52 PM

Oh right. I see what you mean. Lag usually means a loss in fps, so I got confused.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users