How can I connect two object to move in tandom?

I have a platform game the has a tank body and the cannon of the tank moving together as one. But when I start the rotation of the cannon it looses alignment with the tank body. Is there a way I can connect the two actors so they move together and behave normally?

Comments

  • FrantoFranto Member Posts: 779
    edited January 2014
    Make two game attributes for your characters self.x and y. Use constrain attribute to do this. Then make another character and constrain their x and y positions to the game attributes that are linked to your main character. On both, put the same movement behaviors. For example, make a behavior that moves left if game boolean left is true. Then make another behavior with the condition that when left is true, move/accelerate left by whatever number. Put these two behaviors on both actors so when you press the key, both move in tandem.

    Also, if you want the character to be slight above or below the main, while still moving in tandem, in the constrain attribute for the x and y, put + or - on the position so they will be that distance from the center of the main character. - for left(x) or down(y), + for right(x),up(y).

    EDIT: I found this out while trying to figure out how to make my character attack from any angle without rotating the actual actor in a platform with gravity. I had made another invisible actor that rotates so that attacks can be aimed in any direction without affecting the main. Although, I messed up when arranging the behaviors and had a bug that at the time I couldn't solve but days later, I finally figured out what was missing to fix it, but decided to go back to it later when I had the time.
  • pixelpowervfxpixelpowervfx Member Posts: 8
    You sound like you have been at this more than I have, I think I understand though, I am still learning the relationships of each attribute and behavior; and how they relate to each other. It is weird that even though you don't need to know programing, there is still a lot of programming. It would be cool to have drag and drop pre-made nodes that do exactly what they say. Like if you want a camera to follow an object you drop a camera follow in that actor and it will do it for you (example). Thanks for your insight and help!!!
  • FrantoFranto Member Posts: 779
    You're welcome. I just found Game Salad 3 weeks ago and have been eating up all the info I could get in my spare time. I started out thinking I wouldn't be able to understand it to being able to implement stuff on my own. I theorize that even though using this program looks difficult, it's probably only 1/10th or even 1/50th as difficult as actual programming. I bet an entire page of code is written for each behavior.

    I also like how some attribute formulas can use math to do interesting things. I managed to make an awesome attack that changes size and shrinks depending on a power meter and depletes when the energy meter runs out.

  • SocksSocks London, UK.Member Posts: 12,822
    I have a platform game the has a tank body and the cannon of the tank moving together as one. But when I start the rotation of the cannon it looses alignment with the tank body. Is there a way I can connect the two actors so they move together and behave normally?
    Can you be more specific, in what way does the cannon 'loose alignment' ?
Sign In or Register to comment.