- Home /
How to make weapon orbitiong player and follow the camera at the same time like shown in video below?
I'm trying to make some neon style rougue-like game with a sphere that represents a main character.... And i'm really stuck with this gun issue cause when i'm making it a camera child object....well....it's not working properly. How can i make it orbiting player, changing rotation of it when player moves to certain direction and take control of it with mouse any time? Seems like it's really comlicated question, but still... Here is the video btw : https://youtu.be/OU3B3D-52us?t=359
Answer by Michio888 · Jan 04, 2021 at 01:49 PM
Sorry.... I solved it already. Just created an empty GameUbject and atteched the gun to it and added script to this object as well.
Here the code if someone would need it
public class WEAPON_FLOW : MonoBehaviour
{
public Transform followSphere;
public Transform CamTransform;
void FixedUpdate () {
transform.position = followSphere.transform.position;
transform.rotation = CamTransform.transform.rotation;
}
}
You could also just make the weapon a child transform of the character transform, in that way it follows and rotates around as the parent transform does.
Your answer
Follow this Question
Related Questions
Help with Lerp 0 Answers
Creating a Mounted turret 1 Answer
How To Make Camera Follow Bullet? 2 Answers