Player Movement

Anyone know how to make a Character follow another one kind of like SNES RPG's where u have 2-3 people on party and they follow each other.

The closest I have come so far was :

Variables in Game - IsMoving,IsLeft,IsRight,IsUp,IsDown,Char1X,Char1Y

*When Left is Pressed set IsLeft to True

*In Char1- If IsLeft = True, Set IsMoving to True, MoveTo -Char1.Width,0 and change Char1X to self.position.x, Char1Y to self.position.y

Then in Char2 I have -

*If IsMoving = true, MoveTo Actor1X,Actor1Y

Not sure if I forgot anything but as of now it works - unless I spam Left Actor really fast then Char2 moves inside Char1. Follows in sort of a "snake" like fashion.

My problem is that I feel like multiple taps to move around might be annoying so I'm trying to make it -

Press Left - Set IsLeft=true

Char1- If Isleft = true Timer every 0 seconds - moveTo - MoveTo -Char1.Width,0 and change Char1X to self.position.x, Char1Y to self.position.y

This allows Char1 to move by size when Left is Pressed, but then player 2 doesn't follow right.

*Is there a fix or an easier way to achieve this?

*Would this way also cause problem for animations, Example being if Char1 moves left, Char2 would have to move up first, and then follow from there.

Thanks.

Comments

  • ImpervionImpervion Member Posts: 49

    *Also how do I fit 1000,2250,3456,etc monster Hp into a health bar 100px in Length.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Are your characters moving on a grid? You got into the nitty gritty pretty quickly but it would help to know the big picture a bit. Can you provide a sketch or screenshot of how characters should move? Or at least describe it a bit more. For example, "When character #1 moves right 80 pixels, character #2 should do the same at the same time but character #3 should move 120 pixels to the right 1.5 seconds later."

    *Also how do I fit 1000,2250,3456,etc monster Hp into a health bar 100px in Length.

    Use a small font?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ImpervionImpervion Member Posts: 49

    Here is the screenshot(I hope):
    [img]http://i.imgur.com/D5bK6MS.jpg[/img]

    That's with me pressing Left and then Down. So Start Position>Move Left>Move Down. For the pictures.

    As for the Health Bar, I could only find guides with static like Hp Bars, I Want one to be larger then the 100 Hp stats 100pix length bar.

    Some replicated 1px to Health Points, and some multiplied or divided(forgot which), to fit a 100px preset Length Hp Bar. So with me wanting more then 100, I cant have it replicate off screen, or set the length of the HP Bar to the size of 3000, again going across the screen.

  • ImpervionImpervion Member Posts: 49

    Might be confused by the Health Bar, I want to contain Eg. 10,000,12,986 hp into a Actor:Health Bar 100pix Long, and then When damage is taken reduce hp-damage, and the bar "shrinks" accordingly.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Uh, okay. So just divide the health attribute value by some constant, say 200, and then use that result for the width of your health bar. Not sure why you have health in the tens of thousands but that should do the trick.

    In the series of three images, which color is which character? In other words, which color square are you moving initially and which other colors are following?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ImpervionImpervion Member Posts: 49

    Red = Char1, Blue = Char2, Green = Char3

    It works, but constantly tapping to move atm(32 pix, char size being 32x32), jsut seems a bit annoying.

    Also what do you mean a constant, Like, 1000hp/10=100, but what if its 3689hp, the divide by 10 wont work.

  • SocksSocks London, UK.Member Posts: 12,822

    @Impervion said:
    Also what do you mean a constant, Like, 1000hp/10=100, but what if its 3689hp, the divide by 10 wont work.

    True, diving by 10 stops working at around 1,400, just a weird quirk of maths :tongue:

    But seriously, 3,689 / 36.89 = 100.

Sign In or Register to comment.