I am following Unreal's tutorial titled Twin Stick Shooter with Blueprint. I am on the step called Respawning the Hero. I've done all of the instructions for that step, but when my player is respawned, they fall through the floor. I am using Unreal Engine 4.26.2 which is a different version than the tutorial uses.
In my game mode, I've tried all available settings of Collision Handling Override within Spawn Actor from Class. In the Class Defaults of my player, I've tried all options for Spawn Collision Handling Method. I've made sure that my PlayerStart is above the floor. None of the solutions I've found by searching have applied to my issue, as far as I can tell.
Thanks!
Within TwinStick Mode
Within HeroCharacter
Within HeroCharacter
Your HeroCharacter spawn location is not set. and thus the location is (0,0,0).
Connect output execution pin from Set Game Mode node to the Set Player Spawn Transform node.
Related
So I've been making this online survival game using mirror and I have come across an issue with spawning in a weapon for the player.
Apparently you can only parent an object to another networked object (when executed by the server).
When I was doing this in single player I had no issues obviously as I could just set the parent to my camera holder game object and it will follow the cameras rotations as expected.
Now for the client to see the other players spawned equippable, I can only seem to set the parent of the equippable to the player transform where the network Identity/transform is.
If I go to set it to the camera holder then nothing happens, the equippable will just spawn in at 0,0,0.
So with this said, is this the only way to do this? Have a ClientRpc tell the client to parent the equippable to the root of the player and then have code on the equippable to follow the camera?
I feel like I'm missing something important as this method seems quite finniky.
Thanks in advance.
I have tried putting another network transform on the gameobject I would like the parent to be set.. mirror doesn't like this, was hoping it would parent but it just goes to 0,0,0
I have tried to code moving the equippable with the camera but I wasn't getting good results so I thought I would ask here if there was a much easier and or practical way to execute this.
Is there a way to share each player's raycast pointer/cursor with the other players in realtime? I'm using PUN2 and MRTK2 and Hololens 2.
Approaches I've tried so far:
I tried a naïve approach of modifying the MRTK provided ShellHandRayPointer to contain a PhotonView and then using that on the MixedRealityToolkit object within the scene, but that seems to have no effect.
I've tried creating a cursor prefab based off of MRTK's CursorFocus in which I add a Surface Magnetism component (tracking the hands) and then instantiate this prefab for each player in PUN2's OnJoinedRoom callback. After the instantiation call, I add the object to a non-rendered layer for the player with the goal of hiding it for the local player but allowing it show up for other players. This seems to hide the object as expected when only one player is in the room, but when a second player joins, the first player then sees a cursor show up that tracks with their hand movement, which seems unexpected to me (of note is that I'm using one Hololens 2 headset with a computer acting as the second player). Though perhaps this "crossed" behavior is due to the Surface Magnetism component?
Thanks!
Step-by-step images of how I modified the ShellHandRayPointer with a PhotonView and then reattached to the MRTK system:
scene:
MRTK system:
MRTK system part 2: reference to cloned ShellHandRayPointer:
my cloned ShellHandRayPointer part 1:
PhotonView components expanded on the cloned ShellHandRayPointer:
Regarding how to share objects in Photon in real time, as far as I know, the real-time shared objects in Photon need to be instantiated by PhotonNetwork.Instantiate, but ShellHandRayPointer in MRTK is instantiated by Input system.
You can customize a copy of ShellHandRayPointer, map the position and rotation of ShellHandRayPointer to the copy at runtime and share this copy in Photon in real time.
The position and rotation of ShellHandRayPointer can be obtained in MixedRealityToolkit.InputSystem.DetectedInputSources. Or you can use Unity's methods to get this Game Object directly.
For the cursor, you can use the same method above to create a copy of the cursor and map its position and rotation.
I'm having trouble finding the missing piece of the puzzle with my blueprint here. Under my turret blueprint, I'm trying to check if the turret is dead, if it is, then it executes the scoring system and adds some points. What I have here is not working though. Can someone help me find what I'm missing? Thanks.
Turret Blueprint
You've attached your code to the Event BeginPlay node which means your game will only check the turret and try to add points once, which will happen as soon as the game starts. We would need to know what causes your turret to "die" to give you a more accurate answer, E.g. is it hit by a projectile or a melee weapon, or does the player have to find their way to a switch to turn the turret off or blow it up etc.
You first need to identify the cause of the turrets death and trigger your score update from there. If for example your turret is destroyed by a projectile which the player shoots at it, you could check when another actor overlaps (I.e. hits) your turret and then check if the other actor is the player's projectile. If it is, you can then update the player's score and destroy the turret.
It is also usually best to store the player's score in the PlayerState instead of the GameMode. You would need to create your own PlayerState blueprint and configure your GameMode to use that blueprint. This can be done in the properties of the GameMode or in the project settings under Maps and Modes.
Below is a basic example of destroying a turret with a projectile and updating the player's score. But I would recommend searching YouTube for something like "ue4 damage enemy" or "ue4 dealing damage". There are loads of tutorials which will show you how to implement a damage system step by step.
Turret Blueprint
This blueprint uses the Event ActorBeginOverlap node to detect when another actor overlaps/hits the turret (both the turret and the other actor will need to have a collision box or sphere etc). Then it casts the other actor to BP_Projectile (a custom blueprint/actor which you would need to create). If the cast fails, the 'other actor' isn't a projectile so we don't want to destroy the turret. If the cast is successful, we can then get the player state from the player controller and call Update Score which is a custom event I've made in my PlayerState blueprint, passing the number of points killing the turret will give you. After updating the score we can destroy the projectile and then the turret itself.
Player State Blueprint
This blueprint just has a custom event which updates the PlayerScore variable.
Here's a problem: my goal is to have a ball game with obstacles. I made two obstacles (cubes with triggers) and the spawner code does not spawn them - nothing at all. It does compile without errors, but just does not work. These blueprints are part of the track class (the track the ball is on). Here is the code: (obst amount = 7 - the code before it works fine - its linked to event tick)
Here are the obstacles: (no code in them)
Here is the track:
I'm using Unreal Engine 4.26.2
If it is showing up in the outliner, but you don't see it here's what I would try.
First, unplug your X and Y location. Manually input something you know is right in front of the player.
If you can see it after that, start printing the the coordinates of the spawn location. If those look right and you can't see it still, try spawning a regular cube instead. If you could see the cube but not your obstacle, then I'd check the obstacle BP. In that case it's likely either the scale of the mesh component or it's set to be hidden in game.
Sorry I know this isn't a definitive answer, but I don't have enough reputation to comment instead.
I have a SteamVR Unity project which I'm converting to multiplayer.
When another client joins the game, instead of two different players seeing each other, each player has it's own version of the game where he controls all fo the player instances.
For example, while one player is connected everything is fine, but when a second player joins, the game just adds another Player prefab which the first player controls as well.
I tried replacing the Player with a simple cube and everything seems fine.
both the Player and the cube have Photon Transform View and Photon View scripts.
I would appreciate any help I can get.
This is a common problem, when you start with PUN. You probably setup a player prefab with network synchronization and instantiate that for each player. All scripts on the instances will act on the local input, which is what you see now.
You want two variants of the prefab, for local and remote representation. As it's impractical to always configure two prefabs, instead you build one which initializes itself (in Awake or Start) as local or remote. Your scripts should check the object's PhotonView if it's .isMine or not.
This can be done per Component (in each distinct script) or you could add a component which enables/disables the scripts on a GameObject, depending on isMine.
The Basics Tutorial does this, for example.
Unity doesn't know if it's multiplayer or not. When you give an input all of the scripts who are waiting for input takes it and behaves accordingly. To solve this basically create another player that doesn't take any input and spawn it for other players.