Question by
maliimaloo27 · Oct 01, 2017 at 02:09 PM ·
move object
move a cylinder from a script on the player
Hello,
I need help because my problem is that I would like to rotate my cylinder left or right, but the script that will allow the cylinder to move is not installed on the cylinder but on my player.
I tried to do it with all my knowledge as well as the knowledge of my beautiful brother with whom I make a games without any success so I turn to you, if you could help me, it would be super nice because it will allow me to finish my games.
Comment
//File move Cylinder
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class $$anonymous$$oveCylinder : $$anonymous$$onoBehaviour
{
public PlayerDeplacement deplacementJoueur;
public float rotationSpeed = 30.0F;
string sensCylindre;
string movement = "";
string mouvementRotatif = "";
float rotation;
public void Start()
{
string sensCylindre2 = deplacementJoueur.testCylindre();
sensCylindre = sensCylindre2;
}
void Update()
{
mouvementCylindre(movement);
}
public void mouvementCylindre(string sensCylindre)
{
//sensCylindre = deplacementJoueur.testCylindre(movement);
//sensCylindre = "Horizontal";
//sensCylindre = "Right";
//sensCylindre = "Left";
rotation = Input.GetAxis(sensCylindre) * rotationSpeed;
rotation *= Time.deltaTime;
transform.Rotate(0, rotation, 0);
return;
}
}
// on file move player
public string testCylindre()
{
movement = "Horizontal";
//movement = "Right";
//movement = "Left";
return movement;
}