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

parabola for the beginner?

Discussion in 'Scripting' started by pr0ph3ts, Jun 5, 2014.

  1. pr0ph3ts

    pr0ph3ts

    Joined:
    Jun 1, 2014
    Posts:
    4
    Thank you for taking the time to read this, i recently started to learn c# at the same time as messing around with unity. My question is, how would i go about making this type of game mechanism, i have created a jpeg example;



    I would like to be able to click mouse button and create the knife object, then launch it kind of like the mechanics to the angry birds catapult.

    If anyone can point me in the right direction to achieve this i would be forever grateful.

    Thanks peeps!
     
  2. pr0ph3ts

    pr0ph3ts

    Joined:
    Jun 1, 2014
    Posts:
    4
    By the way i am not asking for a script to be given to me, i am asking for an explanation as to how to go about understanding this problem so i can further my c# skills. Thanks again
     
  3. TheSniperFan

    TheSniperFan

    Joined:
    Jul 18, 2013
    Posts:
    712
    I'd probably not implement it myself. Unity has a build in physics engine; Use it!
    When throwing you either apply a force or set the velocity, then let Unity handle the rest. You'll need to tweak the values (mass, gravity, force/velocity when throwing) though.

    There should be multiple ways to determine whether the handle or the blade hit the target. The easiest way would be to have the knife consist of two GameObjects (blade and handle), then use the OnCollisionEnter() methods.
    The handle does nothing (maybe play a sound or something), while the blade does stuff like enabling the blood (particles?), stop the knife from moving and whatever you want to happen (score?).

    As for the camera following the knife:
    Have a look at LateUpdate(). ;)

    Hope this helps.
     
  4. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    There's no reason to have the knife be 2 objects. If the forward vector of the knife is the point then you can check the dot product of that vector and the up vector of whatever you're trying to hit to determine how much of the point is facing towards the target.
     
  5. pr0ph3ts

    pr0ph3ts

    Joined:
    Jun 1, 2014
    Posts:
    4
    That makes some sense to me dude thanks a lot it does help yes. Now i kinda know the things ive gotta play around with. Cheers!
     
  6. pr0ph3ts

    pr0ph3ts

    Joined:
    Jun 1, 2014
    Posts:
    4
    what do you mean by dot product?
     
  7. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
  8. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    Also, there is a Vector3.Angle which does the same thing without requiring that you have any idea what "dot product" means.