How do i create an object that instantiate from another screen but have different behavior?
What i try to do is,
I have a floating character on scene 1, but when i bring it on scene 2 i want to add rigid body, but if i attach rigid body on the character, it just drop down to the endless bottom at scene 1…
so is there any way around that could flag the rigid body?
maybe by activated/deactivated it at different scene?
So now that I’ve looked at your project the problem’s pretty clear. The code you’ve got woks perfectly but your character isn’t colliding because both your character and the floor are mesh colliders. Mesh colliders don’t interact with other mesh colliders so you have to replace either your character’s colliders or the floor’s collider with a different type. I would recommend replacing the character’s collider to a capsule collider and shaping it to cover it’s entire body so that it can move up slopes easier and can interact with objects using mesh colliders.
ok, it;s solved, it can collide now, but my character now rolling like a ball.. what should i do? because the collider now is you know, not flat at the bottom.. Thanks so MUCH EnglishMufin123
So this depends on how you want to control the character. You can go into your rigidbody constraints and check the rotation constraint for the X and Z axes. Another option would be to use a character controller.
so i was trying but no possible outcomes, should i made this on new javascript and attach it on Main Camera at the new scene? so its like when level was loaded, find this gameobject and attach rigidbody?
One answer to this would be to create an empty object in each scene to handle these changes. I always keep handler scripts on an empty object. You can then access the object and activate or deactivate it based on the scene.
ok i've try it and it's working, but my object keep going down even thou there's floor below him :/ function OnLevelWasLoaded(level : int) { if(level==3){ Debug.Log("you success !"); GameObject.Find("testchar_F").AddComponent(Rigidbody); } }
but my object aldy have collider in it, from the start i attach sphere collider to it, any other suggestion Muffin? btw thanks for answering so much of my question
ok, it;s solved, it can collide now, but my character now rolling like a ball.. what should i do? because the collider now is you know, not flat at the bottom.. Thanks so MUCH EnglishMufin123
– RgalaxySo this depends on how you want to control the character. You can go into your rigidbody constraints and check the rotation constraint for the X and Z axes. Another option would be to use a character controller.
– EnglishMuffin123