I am creating a game in unity. and i got a problem with drag on a moving object. if a object is falling on a moving object its not moving with the moving object. i already tried to bring the drag of the moving object higher, but that didnt work. so the question is is there a script or other option in unity. the object has to move with the moving object but it still must have the option to fall of it.
var plane : Plane = new Plane(Vector3.up, Vector3.zero);;
var particle : GameObject;
var shootcounter: float=0;
//dit zorgt ervoor dat je muntjes kan gooien in het spel.
//de shootcounter zorgt ervoor dat er tussen elke worp op zijn minst een halve secende tussen moet zitten.
//ook zorgt dit script ervoor waar de muntjes vallen.
function LateUpdate()
{
//de shootcounter zorgt ervoor dat er een halve seconde tussen de muntjes moet zitten.
if(shootcounter<1)
{
shootcounter = shootcounter +Time.deltaTime;
}
// dit herkend waar je klikt met je muis.
if (Input.GetMouseButton(0))
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var ent : float = 100.0;
if (plane.Raycast(ray, ent) Score.muntjes >0)
if (plane.Raycast(ray, ent))
{
//dit zegt of waar je klikt dat daar een muntje mag vallen.
//en laat het vallen als het mag.
var hitPoint = ray.GetPoint(ent);
if(ent < 46 ent > 40 shootcounter > 0.5)
{
var go = Instantiate (particle, transform.position, transform.rotation);
go.transform.position.x = hitPoint.x;
go.transform.position.y = 13;
go.transform.position.z = hitPoint.z±11;
shootcounter=0;
Score.muntjes–;
}
}
}
}
is dopping on:
var tel : float = 0;
var richting = 0;
static var snelheid = 5;
//dit laat de dozer heen en weer bewegen.
function Update ()
{
//zelfde geval als met de balken.
if(richting==0)
{
tel = tel+Time.deltaTime;
transform.position.z -= snelheid * Time.deltaTime;
if(tel>2)
{
richting = 1;
}
}