JeffJ
Member
1: I have a rectangular area that can move around and rotate
2: I spawn a number of small objects in a random area within that area
3: These small objects have a direction and speed of their own
4: I need these objects to follow their "parent square" with respect to their current position
This works fine, but breaks the moment I try to make the following based on a vector rather than simple coordinates.
The thing is, it's pretty much like spawning a bullet at the tip of a gun with the lengthdir functions, except here the position isn't static in the same way, and for some reason I've just hit a logic brick wall now.
This is what I currently have in the small spawneable object's step event:
What I'm trying to do here is first make it follow the coordinates. Then I take the object's starting position (basically its xstart/ystart) and subtract the rectangle's coordinates to get the distance from the start of the square to the object's position. I then use that distance to try and calculate a vector and offset the position using that, but the positions ends up being all over the place. I've tried several different variants of the above, and I'm clearly just drawing a logical blank.
If you'd prefer to see the whole project, here it is - it's just two objects and there are printed control instructions on the screen when you run it.
http://megafuzz.com/CustomParticle00.yyz
EDIT:
If I just do this in the step event:
It's pretty close to what I want, but then the issue is that the objects don't follow the rotations. I need them to not only follow based on the rotation, but also maintain their motion.
2: I spawn a number of small objects in a random area within that area
3: These small objects have a direction and speed of their own
4: I need these objects to follow their "parent square" with respect to their current position
This works fine, but breaks the moment I try to make the following based on a vector rather than simple coordinates.
The thing is, it's pretty much like spawning a bullet at the tip of a gun with the lengthdir functions, except here the position isn't static in the same way, and for some reason I've just hit a logic brick wall now.
This is what I currently have in the small spawneable object's step event:
Code:
//objController is the rectangular area that moves and rotates around
direction=objController.angle-global.swordAnglePrev+90 //swordAnglePrev is objController's direction set in its end step event
deltaX=objController.x-objController.xprevious;
deltaY=objController.y-objController.yprevious;
x+=deltaX;
y+=deltaY;
myOffsetX=myStartX-objController.x;
myOffsetY=myStartY-objController.y;
lX=objController.x+lengthdir_x(myOffsetX,objController.image_angle);
lY=objController.y+lengthdir_y(myOffsetY,objController.image_angle);
x=lX
y=lY
If you'd prefer to see the whole project, here it is - it's just two objects and there are printed control instructions on the screen when you run it.
http://megafuzz.com/CustomParticle00.yyz
EDIT:
If I just do this in the step event:
Code:
direction=objController.angle-global.swordAnglePrev+90
deltaX=objController.x-objController.xprevious;
deltaY=objController.y-objController.yprevious;
x+=deltaX;
y+=deltaY;
Last edited: