User Tag List

Results 1 to 7 of 7

Thread: Attaching shadows to active objects

  1. #1
    Clicker Fusion 2.5 DeveloperiOS Export Module

    Join Date
    Apr 2009
    Location
    Paris, France
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Attaching shadows to active objects

    I suspect this is really easy and I'm just too tired to figure it out (it's late). Help!

    I have an active object (character) with multiple instances. I'm trying to attach a semi-transparent shadow to each instance. Obviously, the shadow needs to track the movement of the associated instance.

    Here's what I've got so far:

    Start of Frame
    + Spread 1 in Alt G of Active Object

    Always
    - Start loop "CreateShadows" NO Active Object times

    On Loop "CreateShadows"
    - Alterable Value G of Active Object = LoopIndex("CreateShadows") + 1
    - Active Object NOT overlapping Shadow Object
    + Create Shadow Object at Active Object

    On Loop "CreateShadows"
    - Alterable Value G of Active Object = LoopIndex("CreateShadows") + 1
    - Active object overlapping Shadow Object
    + Set Shadow Object x,y to Active Object x,y

    The code above works fine... UNTIL two characters get close to each other and their shadows overlap other Active Objects. Then bad stuff happens.

    Is there a better/easier way to do this?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Hi Cybert9. You're making it harder work than it needs to be! Just do this.

    Give both the object and the shadow an Alterable Value called 'ID' (or just use Alt G like you did up there, I find it's better to name values).


    To stick the shadows to the objects, it's very simple, just these two events:
    * Start of Frame: Spread Value 1 in 'ID' of 'Object', Spread Value 1 in 'ID' of 'Shadow'
    * 'ID' of 'Shadow' = 'ID' of 'Object': Set position of 'Shadow' to 0,0 from 'Object'



    This works if you have the same number of shadows as you do objects, and you never destroy any of the objects. Add these two lines, though, and you can make it failsafe, to always ensure that you have the same number of shadows as objects, and that any shadow tied to an object which has been destroyed will be destroyed too!

    * Number of 'Shadow' < Number of 'Object': Create 'Shadow' at (any position outside of the frame), Spread Value 1 in 'ID' of 'Shadow'
    ^ Note that we spread the values again, this is important! We need to spread the value again every time a new one is created (or set the value to number of shadows+1, but this is safer).
    * Number of 'Shadow' > Number of 'Object' + Pick one of 'Object' at Random: Destroy 'Object', Spread Value 1 in 'ID' of 'Object', Spread Value 1 in 'ID' of 'Shadow'
    ^ We spread BOTH values again in this event, also important! It ensures we don't have a shadow/object ID mismatch when one is destroyed!


    That's all you need! No fast loops at all! It just sticks the shadow to the object with the same ID as it. If you don't have the shadows for each object already in your frame and you notice shadows being 'created' (as in they quickly pop in one by one at the start if you don't have them in the frame already) after adding this code and you find it unpleasant, you can use a simple fast loop to create the right number of shadows (Number of 'Object' - Number of 'Shadow').

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Sorry, but that's totally wrong.
    Just comparing IDs outside of a fastloop won't work. All that will do is pick the single newest "Object", and match the single "Shadow" with the same "ID" to it.
    Also, you can't spread a value at the same time as creating a new "Object"/"Shadow". It will just set the newly created instance's ID to 1, and leave the rest as they were (so you'll end up with lots of objects all with the same ID).
    Plus, that will only create/destroy a maximum of 1 shadow per frame - so if several are destroyed in quick succession, there will be the wrong number of shadows for a while.
    Just forget spread values altogether - they're not needed here.

    + NObjects( "Shadow" ) < NObjects( "Player" )
    -> Start fastloop "AddShadow", NObjects( "Player" ) - NObjects( "Shadow" ) times

    + On loop "AddShadow"
    -> Create Shadow at 0,0

    + NObjects( "Shadow" ) > NObjects( "Player" )
    -> Start fastloop "DelShadow", NObjects( "Shadow" ) - NObjects( "Player" ) times

    + On loop "DelShadow"
    + Shadow: Pick one at random
    -> Shadow: Destroy

    + Always
    -> Shadow: Set position at 0,0 from Player


    You can actually skip the first 4 lines at just say "Always: Set Shadow position to 0,0 from Player" as long as you always create/destroy a shadow object every time you create/destroy a player.

  4. #4
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Stephen's Avatar
    Join Date
    Aug 2008
    Location
    Montana
    Posts
    4,515
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    There is also a Shadow extension.
    _____________________________________________
    Nivram's Examples -Need extensions? Send me a PM.-


  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MuddyMole View Post
    Sorry, but that's totally wrong.
    Just comparing IDs outside of a fastloop won't work. All that will do is pick the single newest "Object", and match the single "Shadow" with the same "ID" to it.
    Then how come I use it all the time and it works perfectly? You're overcomplicating it.

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    It's probably like I said - the IDs all end up the same, so they become irrelevant (it's just like using an "always" condition, which is what I suggested). Just to demonstrate: https://skydrive.live.com/redir.aspx...094271BBDA!131

    And I'm not overcomplicating it - I'm making it simpler, by not messing around with spread values for no reason.
    The extra part with the fastloops is just to fix a bug that may or may not even be noticeable - it depends on what other events you have.

  7. #7
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleXNA Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    gkinfinity's Avatar
    Join Date
    May 2011
    Location
    USA
    Posts
    284
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yeah you actually don't need spread values to accomplish this

Similar Threads

  1. Attaching several objects to several objects?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 17th March 2012, 03:37 PM
  2. Attaching multiple active objects
    By artician in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 2nd February 2009, 12:56 AM
  3. Make skewed shadows for static objects
    By Popcorn in forum File Archive
    Replies: 7
    Last Post: 27th January 2008, 06:36 PM
  4. attaching objects
    By dub in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 6th December 2006, 11:02 AM
  5. Fastloop with 70 objects+70 shadows example
    By AndyH in forum File Archive
    Replies: 10
    Last Post: 27th October 2006, 03:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •