- Home /
Question by
speed439 · Jan 22, 2018 at 03:59 PM ·
rotationrotate object
rotate position change?????
Hello I want to rotate object i use this
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class KunaiArrow : MonoBehaviour {
public Vector3 point;
[SerializeField]
Transform start;
[SerializeField]
Transform End;
// Use this for initialization
void Start () {
Debug.Log(transform.position.y);
}
void Update()
{
Debug.Log(transform.position.y);
input();
}
// Update is called once per frame
void FixedUpdate () {
checkstates();
}
private void checkstates()
{
if (Player.Instance.arrowrenge==true && this.gameObject.GetComponent<Renderer>().enabled == false)
{
Debug.Log("yes");
this.gameObject.GetComponent<Renderer>().enabled = true;
}
if (Player.Instance.arrowrenge == false && this.gameObject.GetComponent<Renderer>().enabled == true)
{
Debug.Log("no");
this.gameObject.GetComponent<Renderer>().enabled = false;
}
}
private void input()
{
if (transform.position.y < start.position.y)
{
Debug.Log(transform.rotation.z);
if (this.gameObject.GetComponent<Renderer>().enabled == true)
if (Input.GetKey(KeyCode.W))
{
transform.RotateAround(point, Vector3.forward, 20 * Time.deltaTime);
}
}
if (transform.position.y > End.position.y)
{
Debug.Log(transform.position.y);
if (Input.GetKey(KeyCode.S))
{
transform.RotateAround(point, -Vector3.forward, 20 * Time.deltaTime);
}
}
}
}
it work put when i move the player the point change and that annoying i try several ways to make it work put no one work with me
Comment
Your answer
Follow this Question
Related Questions
Problem when i rotate a 2d object aroun Z-axis 1 Answer
How to rotate an object with animation? 0 Answers
Why the player is not rotating and moving at the same time ? 0 Answers
Rotating 2D sprite to match surface. 0 Answers
Rotate Z-Axis towards center. 0 Answers