- Home /
BCE0019: 'Speed' is not a member of 'UnityEngine.Component'.
Please you can help me translate for android. =)
if ( Player ) PlatformSpeed = -1 *Player.transform.GetComponent("PlayerControls").Speed;
if ( transform.position.z < PlatformCreator.transform.position.z - (PlatformCreator.GetComponent("PlatformCreator").PlatformLength + 2) * SectionLength && CreatedPlatform == false )
PlatformCreator.GetComponent("PlatformCreator").CreatePlatform(PlatformCreator.GetComponent("PlatformCreator").NewPlatformCopy.position.z + (PlatformCreator.GetComponent("PlatformCreator").PlatformLength + 2) * SectionLength );
if ( transform.position.z < PlatformCreator.transform.position.z - (PlatformCreator.GetComponent("PlatformCreator").PlatformLength + 2) * SectionLength - 100 )
That is huge and unreadable, edit your question, highlight the code and click the code button (the one with all the 1 and 0 on it)
Answer by whydoidoit · May 27, 2012 at 04:20 PM
Use the version of GetComponent that doesn't take a string but the class name. I.e. remove the quotes from around PlayerControls. Otherwise you would need to cast the result as it just returns a Component
Replace
if ( Player ) PlatformSpeed = -1 *Player.transform.GetComponent("PlayerControls").Speed;
With
if ( Player ) PlatformSpeed = -1 *Player.transform.GetComponent(PlayerControls).Speed;
You basically want to remove the quotes from ALL the GetComponent calls
could you translate all the code because it does not work =)