License from €75 Log in
DE EN FR ES IT CZ

Character's shadow

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 12 years ago
    Hi,

    I was trying to make shadow for the main character somehow through Visionaire, i know it could be done simply if all the animations had shadow inside, but it would be too much work to change it now...

    this is what i've done

    function setCharacterShadow()
    local position
    position = game:getLink(VGameCurrentCharacter):getPoint(VCharacterPosition)
    getObject("Characters[shadow]"):setValue(VCharacterPosition, position)
    end
     
    registerEventHandler("mainLoop", "setCharacterShadow")
    


    It works, but the problem is that the shadow is over the main character ( instead of under ) can i edit the position what i got to i could set a bit different Y position to get the align right?

    Next thing is that i have to set in every scene "if shadow is on scene" action part, which doesn't look much as a good solution..
    Do you have experience with using shadow?

    PS: It's ok to have a bouch of loops in the game, won't be that slowing down the game?

    Thanks for help.
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 12 years ago
    Offset y by 10 pixels or so... wink

    local pos, scn
    
    function setCharacterShadow()
     if game.CurrentScene:getName() == game.CurrentCharacter.Scene:getName() and game.CurrentScene:getName() == Characters["shadow"].Scene:getName() then
      pos = game.CurrentCharacter.Position
      Characters["shadow"].Position = { x = pos.x, y = (pos.y - 10) }
     end
    end
    
    registerEventHandler("mainLoop", "setCharacterShadow")
    


    Try that. The loop will only update if both characters are on the current scene.
  4. · 12 years ago
    Oh great! Now the shadow is behind the character :-)

    With the "if shadow is on scene" a meant that when i go to another scene the character shadow is not going with me.

    if game.CurrentScene:getName() != Characters["shadow"].Scene:getName() then
    -- set Shadow to game.CurrentScene
    
  5. · 12 years ago
    Ah that is also possible to add to the loop...

    local pos
    
    function setCharacterShadow()
     if Characters["shadow"].Scene:getName() ~= game.CurrentCharacter.Scene:getName() then Characters["shadow"].Scene = game.CurrentCharacter.Scene end
     if game.CurrentScene:getName() == game.CurrentCharacter.Scene:getName() and game.CurrentScene:getName() == Characters["shadow"].Scene:getName() then
      pos = game.CurrentCharacter.Position
      Characters["shadow"].Position = { x = pos.x, y = (pos.y - 10) }
     end
    end
    
    registerEventHandler("mainLoop", "setCharacterShadow")
    


    P.S: it's not != in Lua it's ~= for if not. See here for more information about Lua operators.
  6. · 12 years ago
    thanks

    I was looking for some setCharacter function.. and it's
    Characters["shadow"].Scene = game.CurrentCharacter.Scene
    But actually it's not working :/ I'm going to check if everything is ok.

    oh, right i'm still in php.. i'll take a look.
  7. · 12 years ago
    What do you mean it's not working? Could you check the log file please? There are getObject versions to do the script too. Have you upgraded to the latest build of Visionaire Studio? Should be 4.2, build 1182. If not then your build will probably not like my shorthand Lua script code.

    Once shadow character is on the same scene as the current character, the loop should take care of position automatically.
  8. · 12 years ago
    Yes i updated to 1182. I mean when i go to another scene the shadow is not there. It works in the first scene where the shadow is set manually.
  9. · 12 years ago
    The loop should update the characters scene. Are there any errors mentioned in the log? Please enable log level = info in the vs options, if not already set.
  10. · 12 years ago
    I'm having issues with the log file, i have info level, i'm sure that i'm looking into correct folder, but the file is completely empty. I tried print something for testing, but it's not there, it seems to be broken somehow, because it works for new created projects.
  11. · 12 years ago
    try reading it in console (tab) then type: print log
  12. · 12 years ago
    It says failed to open the file.

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?