# Rotating one gameobject around another

Hi, I’m trying to make a simple little 2D space shooter and I have separate prefabs for both the aiming icon and the spaceship. The Arrow (the name of the aiming icon) is a child of the Spaceship and I’m trying to get it to rotate around the spaceship at a constant radial distance and velocity. What are the best ways I could go about doing this? I tried using the rotate method with no success. Here is my code so far:

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Arrow : MonoBehaviour
{
const float MaxSpeed = 1f, AccelRate = 1f, Radius = 0.2f;
float rotateDirection = 0f, angle = 0f;
Vector3 shipPosition;
Vector2 velocity;

// Start is called before the first frame update
void Start()
{
velocity = new Vector2(0f, 0f);
}

// Update is called once per frame
void Update()
{
shipPosition = GetComponent<Spaceship>().transform.position;

rotateDirection = Input.GetAxis("Rotate");
angle = rotateDirection * MaxSpeed * Time.deltaTime;

transform.Rotate(shipPosition, angle);
}
}
``````

Relative Torque The vector of a torque, applied in local space. The object will begin spinning around this vector. The longer the vector is, the faster the rotation.”

OR

I don’t know if this is the most efficient way but I used this to make a shark swim in circles:

I call it in FixedUpdate() so that it doesn’t call Circle() every frame

``````    void Circle()
{
direction = gotomarker.position - transform.position;
direction.y = 0f;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(direction), 0.00242f);//face gotomarker
transform.Translate(0f, 0f, 0.05f);//move forward
}
``````