sidmcfarland's Forum Posts

  • 2 posts
  • Yes. That was the problem. Due to sloppiness, I had two Donkey instances created and I was moving the one that did not already have a tail pinned to it. Rookie mistake.

    In C2, knowing which instance of an object your events are manipulating is not always intuitive. There's no distinction between an object and an instance of an object. It's just called "Donkey". That may get you one Donkey object, several Donkey objects, or none depending on your context. At least, that's my understanding thus far. Please correct me if I'm wrong.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Why do pinned objects become unpinned in functions? Let me explain by example.

    I create two objects. Let's call them Donkey and Tail. Then I pin Tail to Donkey so that moving or rotating Donkey also causes Tail to move and rotate along with it. Great. So far so good.

    OK, let's create a function to move any instance of any Donkey that is spawned. We create a function that is intended to handle all movement of any spawned Donkey. Let's call the function "MoveDonkey", and give it two parameters. The first parameter contains the UID of any given Donkey. The second parameter is the distance to move that Donkey along the X axis. So, to move Donkey, I simply call the function MoveDonkey and pass in the parameter Donkey.UID in Param(0) and an integer value representing how far I wish to move Donkey in Param(1). Within the MoveDonkey function I reference the Donkey instance by calling Donkey's "Pick instance with UID Function.Param(0)". Once picked, I can use Set X on Donkey to Donkey.X+Param(1). This moves Donkey forward or back along the X axis. Works great. So far so good.

    Here's the problem. Inside the MoveDonkey function, Tail has become unpinned from Donkey. Outside of the function, when I move Donkey the Tail moves along with it. But inside the function, the Tail no longer moves with Donkey. It has become unpinned within the context of the function. Why is that and how do I resolve this problem? Do I need to re-pin the Tail on the Donkey within functions?

    EDIT: After further testing, I can confirm this is nothing to do with functions. Forget everything I said about functions. The problem occurs with the "Pick by unique ID" event. Apparently, using this event to pick an object and then moving or rotating that object will not move or rotate objects pinned to it. Still don't know why.

  • 2 posts