An easy way to add shadows to multiple actors?

ChirpinGamesChirpinGames Member, PRO Posts: 214
edited November -1 in Working with GS (Mac)
Hey guys,
Just wondering if theres an easy way to add shadows to my actors.
Ive got about 10 actors per scene and it would take ages to make global variables and manually attach shadow actors to each actor. Is there an easy way to do this?
Thanks!

Comments

  • JCFordJCFord Member Posts: 785
    Unless you wanted the shadows to move around your objects due to a light source, why not just add them to your graphics in photoshop and bring in as transparent PNG's?
  • ChirpinGamesChirpinGames Member, PRO Posts: 214
    Hey JCFord they cant be part of the main actor because of collision rules. Also I'd like them to be offset by about 20px so they will be a fair way away from the main actor
  • rlehmrlehm Member Posts: 320
    Create your shadow image. For a top down shooter, just tint your plane actor black and turn down opacity.

    Create 2 Game attributes. Make them Real

    Call them playerX and playerY

    In the actor you want to have a shadow

    Constrain your players x and y to the new game attributes playerX and playerY

    Then in your shadow actor, constrain his X and Y to the the first actors x and y.

    Now drop the shadow actor anywhere on the screen.

    Expect this to kill your performance if you do it for all your actors.

    Example

    Main Actor:
    constrain: game.playerX to self.position.X
    constrain: game.playerY to self.position.Y

    Shadow Actor:
    Constrain: self.Position.X to Game.playerX
    Constrain: self.Position.Y to Game.playerY

    Also, you can add + or - to offset the shadow so it isn't directly "under" the actor.

    Example would be
    game.player.X+30
    game.player.Y-15
  • ChirpinGamesChirpinGames Member, PRO Posts: 214
    Thanks rlehm. Yep I understand all this but what im trying to do is avoid the global attributes. It would just take way to long.
    Im hoping that maybe theres something where i can just spawn the shadow from the main actor and have it mimick that actor?
  • StuartYStuartY Member Posts: 134
    Constrains are a royal pain in the ass and will hit performance :(

    Have you considered actually embedding the shadow as translucent pixels in your actor's image, and even swapping between two sets of animations depending on whether a shadow is meant to be cast or not? This might yield better results with fewer constrains.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    one thing to consider. if you have a rectangular image (in other words NOT a perfect square) and you set the collision to circle. GS will use the center circle with a diameter equal to the shortest side of the rectangle as the collision area. So you could have a shadow that falls outside of the middle circle and it will not interfere with the collision. This trick only works with circular collision shapes though.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Unfortunately there's no way to do it without killing performance.

    You could unlock each of the shadow instances in the Scene and simply Constrain them to the appropriate actor.

    That will eliminate the need for global attributes - however, depending how your actors move, you will still up to 3 Constrains for each shadow: x, y, and rotation.

    Multiplied by ten actors, that's 30 constrains. Most of the devices would just keel over!
  • ChirpinGamesChirpinGames Member, PRO Posts: 214
    Cheers guys!
    Thats devastating. My graphics look so much better with shadows and really give the levels depth. Without them its not going to look how I'd hoped.
    Fingers crossed the GS team will come up with a way to do this that wont destroy performance.
    Thanks for the advice anyways.
Sign In or Register to comment.