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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Top down game

Discussion in 'Scripting' started by Headshot-exe, Mar 7, 2016.

  1. Headshot-exe

    Headshot-exe

    Joined:
    Jan 14, 2016
    Posts:
    5
    Hey Guys i am making my first game and i am not that much expirienced with unity. Now my Problem :
    I have a ground and a Bridge in my Scene the Bridge is curved. I have 2 Problems. first : when I make the Camera an extra Object and place it as a subobject of Player and My Character too , i can move the Camero with wasd and the Player too, but if the Player hits a Object, the Camera will still move but the Player is stuck. if i make the camera a child object of the Player there are some strugles in the movement, because if I walk over the courved Bridge the camera is moving with the Character and changing its Rotation.
    ".problem: I want my Charakter to walk over the curved Bridge, but for that i need a rigidbody and a box collider.
    If I walk over the Bridge now the Character starts to strugle and even fell off to the side sometimes. Character.PNG Bridge.PNG
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    To your first problem, instead of parenting the camera with the child, consider using one of the many "smooth follow" scripts you will find with a few minutes of searching (including, in the Standard Assets). They all do basically the same thing: make the camera smoothly follow some target, with various limits in rotation, elevation, etc. The target in this case would be your player.

    To your second problem: you don't need a box collider. You just need some collider (because apparently you're using physics). If the box collider is giving you grief — as I would expect, given its sharp edges — try a capsule collider, which is much more forgiving.

    HTH,
    - Joe
     
    Kiwasi likes this.
  3. SwaggyMcChicken

    SwaggyMcChicken

    Joined:
    Apr 13, 2015
    Posts:
    108
    What's your movement system like?
     
  4. Headshot-exe

    Headshot-exe

    Joined:
    Jan 14, 2016
    Posts:
    5
    If I run against an object the screen Vibrates and the Character is spinning a bit is there a way to eliminate that ?

    and another Qeustion ( sry if it sounds dumb but i searched for it like 2 hours and all Things i found diddnt work)
    how can I play an anymatio in js and rotate my character so that I can script that if I press D my Character turns right and changes the animation to walk ?
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Slow down tiger. If you break the question up, googling will help. Like this:
    • How do I play an animation?
    • How do I rotate a GameObject?
    • How do I detect a key press?
    My best recommendation is simply to download the standard assets and import the character controller from there. Forget trying to do stuff on your own.
     
    JoeStrout likes this.
  6. Headshot-exe

    Headshot-exe

    Joined:
    Jan 14, 2016
    Posts:
    5
    Ok maybe I asked a bot wrong. I already have the Key press function. Rotating might be in Character controler but rly I googled like 2 hours and couldnt find any scripts for playing animations that works D: