Complex Actor

Hello,
I need to create an actor composed by more than one part (when the body moves I need legs and arms to follow it!).
Is it possible to constrain the legs' and arms' position to the body's? I couldn't use the "Constrain Attribute" Behavior to directly constrain the actors attributes.
Thanks
Mcccccc

Answers

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    Make multiple images of the actor's movement and put it in an animate behavior.

  • MccccccMcccccc Member Posts: 26

    Thanks MattButlerStudios,
    well, the problem is that I don't need only a graphic behavior which could be obtained with an animation:
    the different parts of the "Complex-Actor" should behave differently and respond independently to different events and actions… I need each part to be an actor itself, just being in a fixed position relatively to the main body.

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    Ok, what exactly are you trying to achieve with the different parts of the actor. Are you sure that these couldn't be achieved visually with animation and the backend could use attributes to make changes in the game?

  • BBEnkBBEnk Member Posts: 1,764

    Why can't you use the constrain it should be straight forward.

  • MccccccMcccccc Member Posts: 26

    @BBEnk: I tried but the editor doesn't give me the possibility to constrain an actor's attribute to another actor's attribute… Probably it's a "jurisdiction" problem, in fact I can constrain it to a game's attribute but not to another actor's attribute. I don't know, am I doing something wrong? It should really be straight forward!

    @MattButlerStudios: well, I need the different parts to interact independently according to the position and direction. For example: how can I distinguish when the actor is hit on its left or right or bottom or top? Is it possible to define attributes for different areas of an actor?

  • MattButlerStudiosMattButlerStudios Member Posts: 486
    edited August 2014

    Just make each part an actor and constrain them to the body. Make rules such as when actor collides with danger - destroy actor But the problem is finding out how to constrain them to the positions that you want.

    One way that might work with constraining them is to first constrain the X and Y values of body to some attributes such as bodyX and bodyY. Then constrain the body parts X and Y to BodyX and BodyY. This will get them to be on the body, but it might not be the exact positioning that you are going for. Maybe you could somehow offset them with angles but I am unsure about that.

  • MccccccMcccccc Member Posts: 26

    @RThurman Great!!! It's exactly what I was imagining! How can I realize it? What about attributes, behaviors and actions? What do I have to link?
    Thanks!

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

    @Mcccccc said:
    I tried but the editor doesn't give me the possibility to constrain an actor's attribute to another actor's attribute… Probably it's a "jurisdiction" problem, in fact I can constrain it to a game's attribute but not to another actor's attribute. I don't know, am I doing something wrong? It should really be straight forward!

    Not wanting to sound rude . . but you might be better off working your way through the GameSalad cookbook, this will give you all the basics about how GameSalad works, time invested here will save you a lot more time in the future - I only say this because constraining one object to another - via a game.attribute - is fairly straightforward stuff and is exaplined in the Cookbook.

    Best of luck !!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @Mcccccc said:
    RThurman Great!!! It's exactly what I was imagining! How can I realize it? What about attributes, behaviors and actions? What do I have to link?
    Thanks!

    Sounds like its time to study GameSalad! The demo shows what GameSalad is capable of doing. (So no saying GameSalad can't handle it.) But your questions indicate that you are probably at the beginning of learning GameSalad's capabilities. This is good! Keep asking questions and studying what this tool is capable of doing.

    But, to be frank, perhaps you should start out on some intermediate goals before you tackle this big one. First steps and all that.....

  • MccccccMcccccc Member Posts: 26

    Ok, thanks guys, I was already studying the cookbook and manual, I think the basics are clear to me, but this problem I can't figure out!

    From the Guide: "Actor attributes can only be accessed by an instance actor, but can be initially defined and used in an prototype actor so that all instance of that prototype can have predefined behaviors ."
    So my question is: why can't I constrain the position of one actor to another actor's position using the ConstrainAttribute behavior?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @Mcccccc‌ -- you can use the Constrain Attribute behavior. But you first need to unlock the instance actor on the scene to access a different instance's attributes.

  • ookami007ookami007 Member Posts: 581

    I have a bounding box actor that I use for collision and an image actor that actually has the image. I connect the two through constrain.

    In the bounding box, I constrain two game attributes playerX = self.position.x and playerY = self.position.y.

    Then, in the image, I constrain it the opposite way...

    self.position.X = playerX
    self.position.Y = playerY

    This works well, but if the actors are different sizes.... then you need to constrain them to the offset.

    So, in this case, the Y is greater, so I do:

    self.position.X = playerX
    self.position.Y = playerY - 6

    That puts the bottom of the image's feet at the bottom of the bounding box, so the collide works correctly.

    You could easily do this with other parts of the body by finding their offsets.

  • bufteabuftea Member Posts: 43

    so the secret was: for x coordinate use the cos() and for the y coordinate use the sin(). Nice!
    I knew it had to be a trigonometry function but I didn't know wich one. I've tried tan(), it didn't work and I got lazy . I've just let the cannon balls to spawn from the middle of the barrel. It was just a test cannon anyway. lol

  • MccccccMcccccc Member Posts: 26

    @buftea‌ Can you explain it better? Why did you use those functions?

  • bufteabuftea Member Posts: 43

    sorry for the late response. i am working on a test game. i just want to see what GS can do and what the steps i have to take until releasing a game. i needed an actor which could move freely and interact with other moving actors. i work on a desktop and using a constrained actor to the mouse didn,t work that well because you keep adding momentuum when you hit an actor with the mouse. so i created a cannon (A simple green rod actualy) which would point towards the mouse, it is also constrained on y axis and moves left to right with a and s key. when i clik the mouse it spawns a ball, but the GS spawns from the center or from a location that is derived from the center ( for example 5 pixels up and 20 to the left). this is were the crazy side appears ☺ . although it is just a test enviroment i wanted it to spawn balls from the top end. but the canon had different locations and angles so simple numbers didn t work to offset the spawn location. if i used x=0 and y=half the height of the cannon this would work only if the canon is pointing up. if u tilt the canon 45 degrees to the left the bal would spawn from the air above the cannon . you need the spawn point to folow the tip of the cannon. that is why you need trig. you just input a formula that takes into consideration the angle of the cannon. i just hope i understood your question corectly ...

Sign In or Register to comment.