GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Has Anyone figured out how to do multi-obj enemies? Or an Eye-Line for an enemy?

fishZombiefishZombie Posts: 46Member, PRO
edited March 2012 in Working with GS (Mac)
I can build a tank with a turret for my hero, but what about enemies?
In order to get the turret to move with the tank, I have to set some game (or scene) level attributes of X and Y.
But.. if I want to spawn enemy tanks (who each have a turret), what then?
The only way I can figure so far is to pre-create all the enemies in the scene, but not make them visible, or keep them just off stage. And each has to be set in the scene editor to look or follow the tank they ride on.

Answers

  • calvin9403calvin9403 Posts: 3,190Member
    then make yours and enemies tank two different actors
  • fishZombiefishZombie Posts: 46Member, PRO
    So, I came up with a way of doing EyeLine, myself, but I can not figure on how to get a spawn-able 2-piece character to work.
    My Eye-Line solution was to create a detection (multiple) actor on top of my HeroActor. Different sizes for different enemies. He carries around the sensor, not them.
    They (sort of) carry around their Eye-Line.
    Each enemy every .3 seconds spawns a rectangle shaped actor called EyeLine.
    It's set relative to Actor with an X offset to make it only stick out the front of the Enemy.
    The EyeLine actor has a timer for every .2 sec destroy this actor.
    Then some collision detection about colliding with the HeroDetection object.
    This means my limitlessly spawnable enemies all have an eyeline, but they are all spawing and destroying things constantly. I'm sure this will cause some LAG when there are 50 on screen.

    Anyone have a better solution?
    I would love a way to parent an obj to another obj.
  • MotherHooseMotherHoose Posts: 2,456Member
    when you constrain the turret to the tank, you are establishing a child-parent relationship

    for a very complex relationship between the turret and the tank …
    involving not just X and Y but rotation and hit tracking etc. …
    it would be much less stressful for you and the user's device
    to have the correct turret/tank actorInstances off-screen and recycle them

    http://gshelper.com/?p=416

    like your Eye-Line implementation! @fishZombie =D>

    @};- MH
  • fishZombiefishZombie Posts: 46Member, PRO
    thanks, but a constraint is not a parent. Having two objects moving in sync, doing the same thing is not a parent. That's twining. A parent relationship is when you have a parent move and rotate, and the child moves along for the ride, with no effort of it's own. Think of your arm. When you move your shoulder, your hand moves with it. It is not doing the same thing as your arm from the same origin. It has it's own rotation point, and is offset by a translation away from the parent's origin. To move your arm around, and then try to animate your hand, to appear to stay at the end is crazy amount of computation. With parents, it stays, without any extra input.
    So what if I have tanks where the turret is off center. i played a game called HM:Defense where tanks have 3 guns on them, all rotating from a point that is not the origin of the body. I was just wonder how they did that, and if anyone had a solution.
This discussion has been closed.