gozinta82's Forum Posts

  • 1 posts
  • Hey Planetheads,

    I'm currently working on a game w/ similar idea (top-down game where player moves any direction, then the upper part of the torso follows the mouse.

    Easiest way I found how to do it was:

    Layout

    1. Create a sprite (can be a simple square/block on the screen)

    -give it 8 direction movement behavior

    -name it 'Player'

    This will be the base for your character, and control the direction of the legs

    2. Create another sprite that contains graphics for the legs (animations) and put this off the screen,

    -set it's visibility to invisible in the properties.

    -Add 'Pin' to the behaviors.

    -name it 'Legs'

    This is a dummy object that should be off the layout as mentioned above.

    3. Create upper torso/head of character by making a sprite and adding graphics for the upper torso of the character (that looks at the mouse cursor)

    -make it offscreen, its again a dummy

    -Add 'pin' to behaviors

    -name it 'Torso'

    -Add

    -lastly make it invisible (should say initial visibility or what not in properties)

    Now we are going to add some code to event sheet to make it all work..

    1. On start of layout, create 'Legs' object and set x,y position to 'Player.X, Player.Y'

    2. Pin 'Legs' object to 'Player' (position & angle)

    3. Set visibility of 'Legs' to 'visible'

    There are the legs

    4. Still on 'On start of layout', add these actions

    5. Create 'Torso' object and set x,y position to 'Player.X, Player.Y'

    6. Pin 'Torso' to 'Player' (position only)

    7. Set 'Torso' visibility to 'visible'

    There is the torso on top of the legs

    -If you have z sorting issues, i always set player to top of layer, then the legs to the top, then the torso to the top, that way each layer will get bumped down as you add an object to the top of the layer

    Next we have to make the 'Torso' look at the mouse cursor

    In event sheet

    add 'System - every tick' then action:

    'Torso' Set Angle Toward 'Mouse.X, MouseY'

    If you are still struggling, msg me and i can send you a capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 1 posts