Portal-like Game: Portal placing and rotation
im new to UE4 and Visual Scripting and i try to build a portal-like game. So i have some issues with shooting the portals to an Object. 1) I created the Portal-Blueprints with a collisionBox and a cylinder. If i shot them to any wall, cube oder something else, the portal is created but it appears skewed, based on the shooting direction to the object 2) If i teleport between the two portals, i always come outside of the second portal in the direction i walked into the first one. This is a key issue if i create the portals and they are on the same direction. It means i enter the first one and face the other one directly after the teleport.
There are a few other issues right know, but i really have to fix those two asap :) I hope someone can help me :)
The missing node on the left side is a OnHit-Node:
asked Dec 07 '16 at 07:11 PM in Blueprint Scripting
When spawning the portal, you're currently setting its rotation to match that of the player. Instead, you should be spawning the portal so that its rotation matches the normal of the wall.
I assume you're doing some sort of collision trace when the player shots out the portal. On that node, there will be a "Hit" or "Hit Result" struct output pin. If you break that, one of the results will be a Normal Vector, which will be a vector facing directly away from the collision where the trace hit. Align your portal with that, instead. (There will be a bunch of functions to convert a direction vector into a rotator or quat you can use for spawning the portal.) Your life will be easier if you rotate your portal asset so it faces down the X axis.
For the teleport facing issue, you'll want to: - Get the relative transform of the player from the portal they're entering. There's a ConvertTransformToRelative function that will do this for you. - Calculate a new transform for the player by multiplying the relative transform by the transform of the exit portal. (In BP, the node you want is called Compose Transforms, I believe. You'll want the relative transform from the first portal hooked up to the A pin, and the transform of the exit portal on the B pin). This will create a final transform which is is in the same place relative to the exit portal as the player was relative to the entrance portal. - Next, you'll want to make the player face the opposite direction, so they'll be exiting the exit portal. Add a local rotation of 180o about yaw to the transform. - Teleport the player to this new transform.
answered Dec 08 '16 at 05:57 AM
i tryed a few other ways and im kinda fine now, but i also got another big problem now. When i teleport between portals, generally the facing issue is solved. But if there is a portal on the ground and i "step outside" a portal on the ground, my camera is completly messed up (see screenshot). I tryed so hard to solve this issue but without any success. I also tryed ur method with the transforms... i cant get it working, im not pretty sure which transforms i should do with the convertTransformToRelative and the ComposeTransform Methods. I feel pretty dumb, tho... Here also an actuall screenshot of my TeleportTo function (It teleports me to the other portal via reference. The Target Arrow is a arrow, connected with the portal). Cheers
answered Feb 06 '17 at 11:33 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here