c# - if (!localplayer) not doing anything -
i'm making multiplayer dodgeball game , every time start host , client, 1 of players can move.
i want players move independently. here (updated) code:
using system.collections; using system.collections.generic; using unityengine; using unityengine.networking; public class script4network : networkbehaviour { // use initialization void start() { if (!islocalplayer) { gameobject.getcomponent<firstpersoncontroller>().enabled = false; gameobject.getcomponent<throwing>().enabled = false; gameobject.getcomponent<headbob>().enabled = false; // gameobject.getcomponent<camera>().enabled = false; } } void update() { } }
this isn't answer because i've been out of unity long, know:
void update() { if (!islocalplayer) { return; } }
does nothing @ all. it's same thing as:
void update() { if (!islocalplayer) { return; } return; }
because every function returns @ end. if we're not local, return immediately. otherwise, return immediately. need way disable input controls -- maybe in start()
find input controls component , disable if !islocalplayer
.
Comments
Post a Comment