- Home /
Portal issue and transform.position
I'm trying to make a portal on which if my player enters, he gets transported to a certain position elsewhere.
Right now I'm using the following logic.
if(tile.tag=="portal")
{
int x = System.Convert.ToInt32(portaldest.transform.position.x);
int y = System.Convert.ToInt32(portaldest.transform.position.y+1);
int z = System.Convert.ToInt32(portaldest.transform.position.z);
player.transform.position = new Vector3 (x,y,z);
print (player.transform.position);
}
This logic seems to be correct, and should work perfectly. The issue I'm getting here is, say my portal destination is the spot (0,0,-3), the player gets moved to a different position which is (0, 0, 3.4) which shouldn't happen. As I even made the position to be an int position.
edit: When printing, it shows the position as (0.0,0.0,3.0) so it should be working. :/
edit2: Just some things you might want to know. The player is a rigid body, use gravity is on, freeze x and z are on. Collision detection is continuous. If I remove the freeze on x and z I can't enter the portal, and if I remove gravity, it's y axis increases to infinity after entering the portal.
Just try to remove sistem.convert and only put transform.position = portalDest.transform.position
Let me know if it works :)
Same issue, which is why I put in the system.convert, hoping it would work :(
Nope, the player is a rigid body thts moving via forced inputs.
can't it be a problem of child/parents? Could u please post a picture of the hierarchy in the scene?
Your answer

Follow this Question
Related Questions
making a non walk through portal 2 Answers
Creating portal camera view with render textur 0 Answers
True Portal Effect 1 Answer
create a portal with texture render 3 Answers
Pixel Perfect 2 Answers