Take an average of the velocity and angular velocity of Parent over the last few frames and set directly on the Child Rigidbody at the moment the object is released.
I'm building a ball throwing app for daydream.
I have a Hand object that reflects the orientation of the controller with a ball object as a child. The parent and child move as I move my controller.
Currently if I release the ball (GvrController.TouchUp) then the child is released from the parent- My problem is it just falls right to the ground.
I've read Here That I should "Take an average of the velocity and angular velocity of Parent over the last few frames and set directly on the Child Rigidbody at the moment the object is released."
How would I format this?
Here is some code I'm working with (Not Working)
using UnityEngine;
using System.Collections;
public class MotionThrow : MonoBehaviour
{
private Vector3 lastPosition;
public Rigidbody rb;
void Start()
{
lastPosition = transform.position;
}
void Update()
{
Vector3 deltaPosition = transform.position - lastPosition;
if (GvrController.TouchUp)
{
transform.DetachChildren();
rb.isKinematic = false;
rb.velocity = (transform.position - lastPosition);
}
lastPosition = transform.position;
}
}
Your answer
Follow this Question
Related Questions
How can I move an object in the direction another object is facing. 1 Answer
C# keep previous velocity while jumping, previous solutions not working 0 Answers
Why is new Vector3 stronger when player is in the air? 0 Answers
How to set rigidbody velocity and angularVelocity to Vector3.zero over time? 1 Answer
Float speed not getting updated on FixedUpdate nor Updated and OnAnimatorMove 1 Answer