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

Game performance difference between using playerperf and getcomponent

Discussion in 'Scripting' started by 987054win, Jun 25, 2014.

  1. 987054win

    987054win

    Joined:
    Apr 12, 2014
    Posts:
    27
    Hi, My problem is I tried to animate my character via a script that is effect by another script and I see two option. First, is to use getcomponent in other script and access player animator to set the parameter value another method is, using playerperf and check the value of playerperf every frame to decide which animation my character will take. Which method is good for my game performance or there are any faster method plss let me know. Thanks in advance.
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,500
    Well, PlayerPrefs isn't really intended as a blackboard, it's intended for storing preferences - as the name suggests.

    On the other hand, getting access to other components is exactly what GetComponent is meant for.

    The question kind of implies that your programming knowledge comes specifically from playing around with Unity. Is that the case? If so, I strongly suggest learning some general purpose programming. Game programming is a specialisation of programming, not a subset, and there's a lot of fundamental stuff you'll miss out on if you don't start from the start.

    Hope that helps!
     
    Sharp-Development and 987054win like this.
  3. Pati-Co

    Pati-Co

    Joined:
    Jan 9, 2014
    Posts:
    56
    I'd like to add: Game programming is a specialisation of programming, often including most difficult areas of it o_O