- Home /
Question by
alexdevAo · Apr 11, 2020 at 11:21 AM ·
rotaterigidbody.velocityridigbody
How to know if the object rotated 360 degrees?
I 'm adding a speed and angularVelocity to a bottle and I would like it to send information when it rotates 360 degrees
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddForce : MonoBehaviour
{
public Rigidbody rigidbody;
private bool swipeUp
public float upForce = 5.0f;
public float rotateSpeed = 10;
private float x;
private float y;
// Update is called once per frame
void Update()
{
if (swipeUp)
{
rigidbody.velocity = new Vector3(0, upForce * y * Time.deltaTime, 0);
rigidbody.angularVelocity = new Vector3(rotateSpeed * y * Time.deltaTime, 0, 0);
swipeUp = false;
swipeUp = false;
launched = true;
y = 0;
x = 0;
if(transform.eulerAngles.x > 359)
{
` `Debug.Log("Rotated 360!");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Rotate RigidBody Sphere 1 Answer
Camera rotation around player while following. 6 Answers
Rotating the weapon back using Quaternion.Lerp 1 Answer
Problems rotating back to zero 2 Answers
Spin a texture in just any material -is it possible? 1 Answer