- Home /
Child of main camera not following correctly
Hello,
In my project I have a First Person Controller, I am trying to make a animated weapon stuck to the player, so wherever it looks, the weapon will follow. (The weapon in the video is the sphere on the screen, for simplicity)
Naturally, I tried parenting the weapon to the main camera. This however does not work as intended, the weapon is way more sensitive than the players mouse itself! I will post a video to explain what I mean, any help is greatly appreciated.
@Pema99 , You attached one script with that object (Sphere). did it effect transform? disable it and test again.
@yashpal 2 Scripts: The one on the sphere is a animation on fire2 clicked script, The one on the frist person controller has nothing to do with the ball.
Removing does nothing
Script 1:
using UnityEngine;
using System.Collections;
public class StartAnim : $$anonymous$$onoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("Fire2")) {
animation.Play ("hitt");
}
}
}
Script 2:
using UnityEngine;
using System.Collections;
public class Shoot : $$anonymous$$onoBehaviour {
public Rigidbody projectile;
public int speed;
void Update () {
if (Input.GetButtonDown ("Fire1")) {
Rigidbody clone;
clone = Instantiate (projectile, transform.position, transform.rotation) as Rigidbody;
clone.velocity = transform.TransformDirection (Vector3.forward * speed);
Destroy(clone.gameObject,2);
}
}
}
Answer by yashpal · Feb 04, 2015 at 05:22 AM
@Pema99, did you use character controller script which is in default assets. Assets -> Import Package -> Character Controller.
Than just take First Person Controller to your scene.
and just add sphere as child of Camera. and you done it.
Your answer
Follow this Question
Related Questions
First Person Controller not working 1 Answer
Rotate child of FPS when camera moves on Y-axis 2 Answers
First person camera restriction. 1 Answer
how to get the child of an instanteated object 2 Answers
Child affecting parent rigidbody? 1 Answer