Rigidbody.AddForce работает в одну и туже сторону

делаю конвейер. но объекты попавшие в него двигаются в одну и туже сторону не зависимо от поворота конвейера.
вот код:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class water : MonoBehaviour
{public float speed=1f;
    void Update()
    {
      Debug.DrawRay(transform.position,transform.forward*2);  
      if(transform.parent!=null){
        if(Input.GetKeyDown (KeyCode.U)){
            transform.Translate(transform.up*0.5f);
        }
        if(Input.GetKeyDown (KeyCode.J)){
            transform.Translate(-transform.up*0.5f);
        }
      }
    }
        void OnCollisionEnter(Collision Coll) {
        if(Coll.gameObject.transform.parent==null){
        if(Coll.gameObject.tag=="res" || Coll.gameObject.tag=="dos" ||Coll.gameObject.tag=="gel"){
            Coll.gameObject.GetComponent<Rigidbody>().AddForce(transform.forward*speed);
            }}

        }
}


Ответы (1 шт):

Автор решения: gordeyka

Сделал. довольно кривая версия объекты прыгают но мне достаточно.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class water : MonoBehaviour
{public float speed=-1f;
    void Update()
    {
      Debug.DrawRay(transform.position,transform.forward*2);  
      if(transform.parent!=null){
        if(Input.GetKeyDown (KeyCode.U)){
            transform.Translate(transform.up*0.2f);
        }
        if(Input.GetKeyDown (KeyCode.J)){
            transform.Translate(-transform.up*0.2f);
        }
      }
    }
        void OnCollisionEnter(Collision Coll) {
        if(Coll.gameObject.transform.parent==null){
        if(Coll.gameObject.tag=="res" || Coll.gameObject.tag=="dos" ||Coll.gameObject.tag=="gel"){
            Coll.gameObject.GetComponent<Rigidbody>().velocity = - transform.forward*speed;
            }}

        }
}

→ Ссылка