Jump to content


Photo

Object speed on creation


  • Please log in to reply
2 replies to this topic

#1 KevinBacon

KevinBacon

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM8

Posted 08 May 2012 - 07:37 PM

Hey
so i want to create an object with speed relative to the creating object whilst enforcing its own speed(not sure if enforcing the right word XP),
what i have is a player_obj with a turret_obj attached,
your moving around with W,A,S,D and the turret_obj is facing the cursor for aiming,
im having trouble with the missile speeds, when a missile is fired it gradually speeds up to max speed, i want the missile to start at player_obj directional speed and the turret_obj image_angle, but i haven't got the no how, the missile is created by the turret.
im creating the missile with.....

with (instance_create(x+lengthdir_x(10,image_angle+85),
y+lengthdir_y(10,image_angle+85),Missile_obj))
{direction=other.image_angle;
image_angle=direction;
speed=player_obj.speed+2;
origTurret=other.id}

help would be nice.
Thanks XD

Edited by KevinBacon, 08 May 2012 - 09:13 PM.

  • 0

#2 Jack Indie Box

Jack Indie Box

    GMC Member

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

Posted 08 May 2012 - 07:58 PM

your code seems fine to me

but if you want additional acceleration for the missile. then just put in the step event
if(speed<targetspeed)
{
speed+=spd/(room_speed*seconds);//spd being the total speed to gain on top of the inital speed. seconds being how long it takes to achieve the speed
}
  • 0

#3 KevinBacon

KevinBacon

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM8

Posted 08 May 2012 - 09:12 PM

your code seems fine to me

but if you want additional acceleration for the missile. then just put in the step event
if(speed<targetspeed)
{
speed+=spd/(room_speed*seconds);//spd being the total speed to gain on top of the inital speed. seconds being how long it takes to achieve the speed
}


isee......thanks XD
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users