Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

tap / click - smooth move to point - with hotspot animations

Discussion in 'Scripting' started by OzDave, Sep 7, 2014.

  1. OzDave

    OzDave

    Joined:
    May 19, 2008
    Posts:
    144
    I wish to make a simple mechanic that allows you to tap or click around on the screen.
    I would like to keep it in 3d but using an orthographic camera simulating 2d.

    An animated sprite or cell changing sprite updates accordingly.

    It has an idle series of frames if not touched, more the merrier on longer timers.
    The camera follows it around on a much larger landscape.
    If the sprite encounters an invisible hotspot, it fires off a specific loop of frames.
    The colours indicate alternative cells of the animation.
    The diagram should explain the rest.

    The last script in this post is sort of correct ( perhaps without force )
    http://forum.unity3d.com/threads/how-to-move-my-character-around-with-forces.235915/

    but a little smoother but needs camera follow, cell swap and hotspot.

    tap_click_move_idea_public.png
    NOTE - this method has been updated using a 3d concept. ignore this diagram
     
    Last edited: Sep 8, 2014
  2. OzDave

    OzDave

    Joined:
    May 19, 2008
    Posts:
    144
    sprite_sheet_public.png I made a super rudimentary spritesheet as well for the exercise
    NOTE - this method has been updated using a 3d concept. ignore this spritesheet
     
    Last edited: Sep 8, 2014
  3. OzDave

    OzDave

    Joined:
    May 19, 2008
    Posts:
    144
    After some consideration last night, I will forgo the 2D sprite component and use an actual 3d model attached to a pivot control object.



    My Temp Project looks like this.
    • tmp_textures
      background.png - less than 1k
      hotspot_a.png - less than 1k
      hotspot_b.png -less than 1k
      ground.png -less than 1k
    • tmp_models
      fish.fbx - 66k
    • scene
      tapMove.unity
    • scripts
      CameraSmooth.cs
      PlayerCollision.cs
    I put this all into a package so you can easily adjust it.
    https://dl.dropboxusercontent.com/u/3053655/TapMoveProject/Media/TapMove_Package.zip Screenshot 2014-09-08 10.33.49.JPG


    I solved the collisions with a temp script for now that can be expanded on later.
    I solved the camera smooth follow script for now that can improve later.

    The interaction of the player is the part I wish to address.
    I want to rotate the fish smoothly but not the underpinning player cube according to the movement.

    I will animate the character in 3d instead of swapping 2d cells like the above concept.


    I have an account for the wiki and happy to share this as a public starting block.
     
  4. OzDave

    OzDave

    Joined:
    May 19, 2008
    Posts:
    144
    So the revised diagram looks like this with the 3d object management in mind, this will make it less fiddly with 2d sprites and all the animations. tap_click_move_idea2_public.png
     
  5. OzDave

    OzDave

    Joined:
    May 19, 2008
    Posts:
    144
  6. OzDave

    OzDave

    Joined:
    May 19, 2008
    Posts:
    144
    Is this where I should be posting for help?
     
  7. OzDave

    OzDave

    Joined:
    May 19, 2008
    Posts:
    144
    Have I picked something hard?
     
  8. AlucardJay

    AlucardJay

    Joined:
    May 28, 2012
    Posts:
    328
    It is really hard to tell what you are asking here. At first glance it seemed like you were actually giving a solution to the community.

    After several readings, my understanding is you want to tell a rigidbody where to move; with a rigidbody that does not rotate to a LookRotation; with a model that does rotate to a LookRotation.

    If you post the script rather than a whole package, I'm sure more help will be forthcoming. (some people just don't want to download a zip file or create a new project just to see the script for helping).