Jump to content


Photo

How To Make A Sword Swing


  • Please log in to reply
11 replies to this topic

#1 nateboy

nateboy

    GMC Member

  • New Member
  • 107 posts

Posted 02 March 2008 - 08:08 PM

ok, so i have my character and his little sword. so ive figured out how to make everything work as long as he is standing still. but whenever he moves the sword stays right where it is. eg. picture a guy moving to the right at a speed of 2 and a sword behind him swinging in midair.

my question is how do i make it so the sword does one of two things. one is make the character stop moving until the sword has stopped swinging, or two make the sword follow the character without restarting the animation?

please make this as simple as possible, and if it is in code please explain how you did it. that way i can learn and wont have to ask you again! :GM072:

Edited by nateboy, 04 March 2008 - 10:18 PM.

  • 0

#2 andrew_berge

andrew_berge

    GMC Member

  • GMC Member
  • 732 posts

Posted 03 March 2008 - 06:32 PM

before you<re caracter<s movement code you could put this

:D if object sword is equal to 0

or in the step event of the sword set variable x to player.x and y to player.y

without restarting the animation


i think you should destroy the instance in event animation end
  • 0

#3 nateboy

nateboy

    GMC Member

  • New Member
  • 107 posts

Posted 04 March 2008 - 01:04 AM

you<re caracter<s movement code


what do u mean by this? i dont know what the "<re caracter<s" means. as for the animation, i tried making it jump to obj_character every step, but then the animation doesnt work. :D
  • 0

#4 Fredo

Fredo

    GMC Member

  • New Member
  • 428 posts

Posted 04 March 2008 - 01:09 AM

what do u mean by this? i dont know what the "<re caracter<s" means. as for the animation, i tried making it jump to obj_character every step, but then the animation doesnt work. :D

<{POST_SNAPBACK}>


I think he meant to put 's there (you're character's movement code instead of you<re character<s movement code)
  • 0

#5 andrew_berge

andrew_berge

    GMC Member

  • GMC Member
  • 732 posts

Posted 04 March 2008 - 04:10 AM

Uh, yeah. my keyboard was set to the wrong language.
  • 0

#6 nateboy

nateboy

    GMC Member

  • New Member
  • 107 posts

Posted 04 March 2008 - 11:34 AM

well, actually, ive been using variables. the only codes i know are rotating and shooting turrets, and saving and loading. i got those from others. :lol:
  • 0

#7 laigonaz

laigonaz

    GMC Member

  • New Member
  • 525 posts

Posted 04 March 2008 - 12:43 PM

This is if the sword is an object

--Step Event--
x=PlayerObj.x
y=PlayerObj.y
//This way is buggy but it will work 99% of the time//

If the sword is a drawing
draw_sprite(SwordSpr,-1,PlayerObj.x,PlayerObj.y)
//This is basic. To draw the sword depend on the direction, use this//
if direction>44.9 and direction<135.1{draw_sprite(SwordSpr,Whatever the subimage number of the down sworf sprite is,PlayerObj.x,PlayerObj.y)}
//Apply this for each direction//

  • 0

#8 andrew_berge

andrew_berge

    GMC Member

  • GMC Member
  • 732 posts

Posted 04 March 2008 - 03:30 PM

This is if the sword is an object

--Step Event--

x=PlayerObj.x
y=PlayerObj.y
//This way is buggy but it will work 99% of the time//


i would recommend putting that in the end step event, otherwise it drags behind the player a bit.
  • 0

#9 laigonaz

laigonaz

    GMC Member

  • New Member
  • 525 posts

Posted 04 March 2008 - 03:32 PM

Oh yeh. I guess I forgot XD
  • 0

#10 andrew_berge

andrew_berge

    GMC Member

  • GMC Member
  • 732 posts

Posted 04 March 2008 - 05:37 PM

I did too! look at my first post
  • 0

#11 nateboy

nateboy

    GMC Member

  • New Member
  • 107 posts

Posted 04 March 2008 - 08:48 PM

my sword is a separate object but instead of using rotations it uses animation. :) so which one of those codes do i use? :lol:
  • 0

#12 nateboy

nateboy

    GMC Member

  • New Member
  • 107 posts

Posted 04 March 2008 - 10:13 PM

i know that you may hate me for this but i have realized im getting too big for my boots! :) while waiting for some help with my problem, i looked at some of the other stuff i had to do and i realized that if you have only been with gm for a month then i shouldnt try this yet. :) still thank you for trying to help me and sorry to have taken your time. :lol:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users