Jump to content


Photo

movement while moving on a path


  • Please log in to reply
6 replies to this topic

#1 M.D.Simmo

M.D.Simmo

    -- ·- - -

  • GMC Member
  • 204 posts
  • Version:GM8.1

Posted 14 April 2012 - 03:51 AM

I have an object (called obj_knife) that moves with a person (called obj_person). When the player attacks, I want the knife to follow a path relative to the players position.
What I currently have is:
// step event of obj_knife
if (path_not_started) {
path_start(pth_swing,8,0,false);
path_not_started = false;
}
x += obj_person.x - obj_person.xprevious 
y += obj_person.vspeed;
The problem is that when the knife is on the path, the 'x +=' and 'y +=' bit does not work.
Is there a better way to do this or a way to fix it?
  • 0

#2 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2297 posts
  • Version:GM7

Posted 14 April 2012 - 05:11 AM

I haven't used paths very much, but perhaps path_shift could do what you want?
  • 0

#3 M.D.Simmo

M.D.Simmo

    -- ·- - -

  • GMC Member
  • 204 posts
  • Version:GM8.1

Posted 14 April 2012 - 05:20 AM

I haven't used paths very much, but perhaps path_shift could do what you want?

I'll try that...


No it didn't work. This is code I tried:
path_shift(pth_swing,obj_person.x - obj_person.xprevious,obj_person.vspeed)
When I tried, nothing changed.

Edited by M.D.Simmo, 14 April 2012 - 05:21 AM.

  • 0

#4 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2297 posts
  • Version:GM7

Posted 14 April 2012 - 05:28 AM

Really aboslutely nothing? I would've expected at worst it would give a screwy path... have you tried putting this in the end step event?
  • 0

#5 M.D.Simmo

M.D.Simmo

    -- ·- - -

  • GMC Member
  • 204 posts
  • Version:GM8.1

Posted 14 April 2012 - 06:57 AM

Really aboslutely nothing? I would've expected at worst it would give a screwy path... have you tried putting this in the end step event?

Yep, no change.
I haven't tried putting it in the endstep event, but why that change it?

EDIT:
I ran some tests, and found some weird results. If someone could please explain what's happening, that would be great.

  • Just trying to change the y value by y += 1:
    on the step event, this will do nothing. On the end step event, this will add 1 and never again
  • Using this code:
    if !variable_local_exists('Y')    Y = y;else     Y += 1;y = Y
    On the step event, this did nothing, yet on the end step event, it worked as it should do.
    EDIT 2:
    placing it on the end step stops the y movement of the path.

Edited by M.D.Simmo, 15 April 2012 - 05:38 AM.

  • 0

#6 kupo15

kupo15

    GMC Member

  • GMC Member
  • 400 posts

Posted 14 April 2012 - 06:59 AM

Just wondering, is there a reason why you want it as a path? Is it a stabbing motion? Can the knife be thrown?
  • 0

#7 M.D.Simmo

M.D.Simmo

    -- ·- - -

  • GMC Member
  • 204 posts
  • Version:GM8.1

Posted 14 April 2012 - 07:16 AM

Just wondering, is there a reason why you want it as a path? Is it a stabbing motion? Can the knife be thrown?

I want it on a path because it doesn't follow a stright path but curves and bends. I'm also probably going to use this code for later objects.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users