- Home /
How do I get a prefab to access a character controller from another object?
I've got a Bolt project that I'm making for college, and I decided that it would involve magnetism. I've got the player movement done, and the level's designed out of cubes so I can quickly make them. The cubes don't change polarity, only the player does. That means I can duplicate all the magnetism scripts between cubes of the same names. The script for a cube which acts as magnetic south is this: The Vector3 MoveTowards at the end should have its right-facing green triangle and vector3 circle going into corresponding connectors on the left of a CharacterController block, but because this is a prefab script, I can't make it select the charactercontroller on the player character. It doesn't show up in the object selector list within the CharacterController element in Bolt. Does anyone know how to select charactercontrollers for other objects within a prefab flow machine?
I found out about "instantiating" so I added that as an instruction that adds on the start. I made the PlayerCube be a prefab so it would theoretically work in other levels, and added a GameObject Literal to select the character controller in it. Thing is, though, with this version of the script, depending on whether the one instance of the Cube1 prefab this script is in decided to override its copy of the script, either the player will clone itself once and shoot upwards until I rotate it; Cube1 will clone itself many, MANY times and make the game run extremely poorly; or everything will seem to work alright but "there's no CharacterController on Cube1" or "PlayerCube CharacterController is inactive". What the hell is going on here?!
I CAN WRITE QUESTIONS!!
assign the player stuff after you instantiate the prefab, not sure how to do that in bolt, C# is so much simpler.
There are 134 people following this question. Why's nobody saying anything?
No many people is experienced enough with Bolt. if you want to recreate the behaviour with c# you will get more help