// Update is called once per frame
    void Update()
    {
        ConstraintSource Current = constraint.GetSource(0);
        ConstraintSource Option  = constraint.GetSource(1);


        //float d = Vector3.Distance(Current.sourceTransform.position, Option.sourceTransform.position);

        //float offset = 3f;
        //d = Mathf.Clamp(d, 0f, offset);
        //d /= offset;

        Current.weight = 1;
        Option.weight  = 0;


        Current.weight -= ballWeight;
        Option.weight  += ballWeight;

        //Current.weight = Mathf.Clamp(Current.weight, 0f, 1f);
        //Option.weight = Mathf.Clamp(Option.weight, 0f, 1f);


        constraint.SetSource(0, Current);
        constraint.SetSource(1, Option);
    }
Esempio n. 2
0
    public void SetOwner(GameObject owner)
    {
        ConstraintSource cs = new ConstraintSource();

        cs.sourceTransform = owner.transform;
        cs.weight          = 1;
        pc.SetSource(0, cs);
        //pc.translationOffset = new Vector3(0, 1, -1);
        pc.locked = true;
        //pc.translationOffset = Vector3.back;
    }
Esempio n. 3
0
    // Start is called before the first frame update
    void Start()
    {
        Player = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity, transform);
        Player.Create();

        ConstraintSource _source = new ConstraintSource();

        _source.sourceTransform = Player.transform;
        _source.weight          = 1;
        cameraParentConstraint.SetSource(0, _source);
        cameraParentConstraint.translationOffset = new Vector3(5.76f, 9.15f, -5.79f);
        cameraParentConstraint.constraintActive  = true;

        Enemy = Instantiate(enemyPrefab, new Vector3(0, 0, -5), Quaternion.identity, transform);
        Enemy.Create();

        GameData.timeBeingChased     = 0;
        GameData.coinsCollectedOnRun = 0;
        GameData.paused = false;

        CoinManager.Manager.CreateCoins(50);
    }