- Home /
Rotation issue with remote players projectiles
Having a bit of issues with some of this code here, the basic idea is i have a networked pilot being instantiated, thats not the problem, moves around and everything perfectly, the problem is my code here for shooting.
What it is currently doing is as soon as it receives the code to fire, its shooting the projectile from the instantiated object straight towards the main ship, which is not what i want it to do.
What i want it to do is whatever the other player ship is facing, i want it to shoot straight ahead, for instance, if forward facing is away from the main player, i want it to shoot that way, if he faces towards the pilot, then it shoots towards the pilot.
What i have it doing is naming each ship object as the pilot name as they log in, and its the string "Name", now "BlasterSpawnOP" is the child spawn object location of each instantiated ship. Also tried different variations of transform.poisition / rotation, etc.. What am i doing wrong?
var BlasterPrefab:Transform;
@RPC
function Shoot(Name:String)
{
var OPlayerGO = GameObject.Find(Name).GetComponentsInChildren(Transform);
for (var child : Transform in OPlayerGO)
{
if (child.name == "BlasterSpawnOP")
{
var Blaster6 = Instantiate(BlasterPrefab,
child.position,
child.rotation);
Blaster6.rigidbody.AddForce(transform.forward * 500);
}
}
}
Your answer
Follow this Question
Related Questions
Camera follow ball along cylinder 1 Answer
How to smoothly rotate to certain directions using input axis 1 Answer
Rotation Jumping values (0 to 180) 1 Answer
Opposite angle rotation 0 Answers
Child versus Parent rotations 3 Answers