Hey guys, i'm trying to recreate this code in playmaker.
I want to fire a bullet and use raycast to register any impact. I store an old position and a new position every frame. The old position is the current position of the bullet and the new position is the position it would reach if the raycast doesn't hit anything.
Bullet {
Update {
newPos += speed * transform.forward * Time.deltaTime;
direction = newPos - oldPos;
distance = direction.magnitude;
if (Raycast(oldPos, direction, distance)) {
Destroy(gameObject);
}
else {
oldPos = transform.position;
transform.position = newPos;
}
}
}
This is what i have, minus the raycast. I just need to get the bullet working right.
I've already got the distance working.
Speed "Float" == 300 (or any speed)
Get Position == oldPos
------------------------------------------------------------------------------
Get Time Info == time.deltaTime
Float Operator == Speed, time.deltaTime, Multiply = newPos
------------------------------------------------------------------------------
Translate == set to newPos
Math is not really my thing so anybody see the obvious mistakes i'm making?