I’m not sure I understand exactly the problem, but follow a very simple example,
using the logic indicated in the @Luizvieira comment, which I believe is the
more efficient for this case (without the need to use Behaviors):
The first object (obj1
) follows the coordinates of the mouse, so to each Event tick your
position is updated as per command:
Set position to (Mouse.X, Mouse.Y)
At this very event, I added a action that increases the size of obj1
as a function of time dt*10
(to simulate the growth of the object):
Set size to (obj1.Width + dt*10, obj1.Height + dt*10)
As the position of object 2 (obj2
) must follow the obj1
, the position
of this object must be related to the properties obj1.X
and obj1.Y
.
To maintain the obj2
away from the obj1
depending on the size, a
possibility is to add the sum of these sizes to the position of the
obj2
(in this example, only on the axis X
):
Set position to (obj1.X + obj1.Width/2 + obj2.Width/2, obj1.Y)
Simplifying the calculation of the position X
, it is possible to eliminate a division:
Set position to (obj1.X + (obj1.Width + obj2.Width)/2, obj1.Y)
The Event sheet gets that way:
And the end result:
Update (in response to comment):
The object obj2
(object superimposing) is connected to the obj1
through the behavior Pin
.
- One possibility to solve the problem is to remove the behavior
Pin
of obj2
and update
its position "manually" with the command Set position to
, whenever there is movement of obj1
(as the answer above).
- Another possible solution is to change the position of the
obj2
with the behavior Pin
disabled in all actions where there are changes in the size of the obj1
. After changing the position of the obj2
, enable the Pin
.
After applying the second suggestion in the above example, Event sheet is as follows:
Welcome home, look at how to create a Minimum, Complete & Verifiable example
– rubStackOverflow
I don’t know in detail the Construct 2. But it would help if you explain what these behaviours do. Probably some of these behaviours are responsible for making the object "grow". In this case, what you can do is calculate the distance between the two objects and move away what grows from each other in proportion to how much it grows. It is more practical, more computationally efficient, and generates potentially better results than using a Colisor.
– Luiz Vieira
And as fellow @rubStackOverflow rightly said, if you provide (for download, with a link to Dropbox, for example) a minimal project example that replicates the problem, it makes it enormously easy for someone who has Construct installed to be interested in testing and helping you.
– Luiz Vieira