R
Rydon_Star
Guest
Hey everyone
I have been looking around for code to just have an object move in an arc between two points. I know there are a lot of forum post out there on this topic but a lot of them are using gravity, etc. which I don't really need. I just need to be able to have an object move from point a to point b in an arc.
I finally found this code to handle that:
speed=0.1;
xx+=speed;
x = max_distance*xx;
if xx >= pi {xx = pi};
yy = sin(xx);
y = max_height*yy;
and I created an object to do this:
CREATE:
///Properties
_speed = .1;
xx = 0;
_distance = 0;
_height = 0;
yy = 32;
_entity = 0;
_endPoint = 0;
STEP:
xx += _speed;
_entity.x = _distance * xx;
yy = sin(xx);
_entity.y = -_height * yy;
if(_entity.x >= pi)
{
_entity.x = pi;
instance_destroy();
}
When I create this object I just assign the object I want to arc and the distance. And this works when I leave all the other variables the same, meaning it starts from 0,0 position. It works great, but when I try to add something like this to take into account the current objects x and y:
xx += _speed;
_entity.x += _distance * xx;
yy = sin(xx);
_entity.y += -_height * yy;
Notice the += for the entity x and y, then my object goes through the roof faster than poochie heading back to his home planet.
I know I have things like the _entity.x >= pi being an issue as it will never be destroyed, but I am not sure how to apply this to an object, regardless of where they are in a room, and have them move 16 pixels to the right in an arc.
I appreciate any help you guys can give me on this.
thanks
I have been looking around for code to just have an object move in an arc between two points. I know there are a lot of forum post out there on this topic but a lot of them are using gravity, etc. which I don't really need. I just need to be able to have an object move from point a to point b in an arc.
I finally found this code to handle that:
speed=0.1;
xx+=speed;
x = max_distance*xx;
if xx >= pi {xx = pi};
yy = sin(xx);
y = max_height*yy;
and I created an object to do this:
CREATE:
///Properties
_speed = .1;
xx = 0;
_distance = 0;
_height = 0;
yy = 32;
_entity = 0;
_endPoint = 0;
STEP:
xx += _speed;
_entity.x = _distance * xx;
yy = sin(xx);
_entity.y = -_height * yy;
if(_entity.x >= pi)
{
_entity.x = pi;
instance_destroy();
}
When I create this object I just assign the object I want to arc and the distance. And this works when I leave all the other variables the same, meaning it starts from 0,0 position. It works great, but when I try to add something like this to take into account the current objects x and y:
xx += _speed;
_entity.x += _distance * xx;
yy = sin(xx);
_entity.y += -_height * yy;
Notice the += for the entity x and y, then my object goes through the roof faster than poochie heading back to his home planet.
I know I have things like the _entity.x >= pi being an issue as it will never be destroyed, but I am not sure how to apply this to an object, regardless of where they are in a room, and have them move 16 pixels to the right in an arc.
I appreciate any help you guys can give me on this.
thanks