- Home /
How to move Groups of Objects using a Script?
Hi, I'm almost completely new to Unity, I only know the basics of everything. I recently tried to make a spaceship type thing using three game objects, that were grouped together by a parent object. However, upon applying the script, NONE of them moved. The Camera I put as a child of the actual Object, however, moves off in the intended direction by itself.
The script I used was literally the basics, and it applies properly (obviously) to a single object. What am I doing wrong?
using UnityEngine;
using System.Collections;
public class EnergyBikeMove : MonoBehaviour {
private Rigidbody rBody;
// Use this for initialization
void Start () {
rBody = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
}
void FixedUpdate(){
float acceleration = Input.GetAxis ("Accel");
rBody.AddForce (rBody.transform.forward * acceleration);
}
}
My Hierarchy is: EnergyBike and Cube are Probuilder cubes with Colliders.
EnergyBike has a Rigidbody which allowed it to move via that script when it was by itself, WITH the camera attached
The Camera is not the default one, but a new Camera I added.
EDIT: For some reason, even REMOVING Cube from under EnergyBike still causes the same problem. DELETING Cube completely, however, solves the problem. I don't understand . . . Upon testing with normal Unity's cubes, this problem does not exist. Is this just a Probuilder thing?
Your answer
Follow this Question
Related Questions
How to make Rigidbody.AddForce less delayed in Unity3D? 0 Answers
How to set a limit for my player rotation ? 0 Answers
Child colliders affecting parent rigidbody characteristics? 0 Answers
Wheelcolliders stuck in ground 0 Answers
Script isn't consistent 0 Answers