Angelwolf Posted November 11, 2015 Share Posted November 11, 2015 I've made a script that will spawn the player in certain places, pending the value of a particular varible. For ease of use, I am using pivots as targets for the spawner. Although I can get the spawner to spawn the player in the right location, I cant seem to get the player's rotation to face the correct direction. How can I make it so the player spawns pointing in a specific direction? Rotating the target pivot doesn't work. For info, the spawner spawns the FPSplayer prefab. Quote My Games: Nightmare Prism:::WolfTale:::Dungeon Creeper:::Despair of Ordinary Men:::Piano Simulator 2016:::House (W.I.P) Link to comment Share on other sites More sharing options...
f13rce Posted November 11, 2015 Share Posted November 11, 2015 You can try the functions SetRotation and Point. You can also take the pivot it's spawning on and set the player to the rotation of the pivot. You'd have to rotate the pivot to the desired rotation though. Quote Using Leadwerks Professional Edition (Beta), mainly using C++. Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz Previously known as Evayr. Link to comment Share on other sites More sharing options...
Angelwolf Posted November 11, 2015 Author Share Posted November 11, 2015 Thank you for your reply, but trying to spawn the player using the pivot's rotation doesn't seem to work. Here's my spawning code: Script.MaxSpawn = 1 --Max spawn level (keep as 1!) FPSPlayer = "Prefabs/Player/FPSPlayer.pfb" --Load the model for the player Script.Target = nil --entity Script.Target2 = nil --entity Script.Target3 = nil --entity function Script:Start() self.counter = 0 --Set spawn count to 0 end function Script:UpdatePhysics() if self.counter >= self.MaxSpawn then return end --Check to see if player is already spawned local player = Prefab:Load(FPSPlayer) --Load the player model declared at the top if Portal == 1 then --Check for flag to determine where player should spawn player:SetPosition(self.Target:GetPosition()) --Set spawn location to pivot 1 player:SetRotation(self.Target:GetRotation()) --Set spawn rotation to pivot 1 self.counter = self.counter + 1 --Tell the script that player has spawned end if Portal == 2 then --Check for flag to determine where player should spawn player:SetPosition(self.Target2:GetPosition()) --Set spawn location to pivot 2 player:SetRotation(self.Target2:GetRotation()) --Set spawn rotation to pivot 2 self.counter = self.counter + 1 --Tell the script that player has spawned end if Portal == 3 then --Check for flag to determine where player should spawn player:SetPosition(self.Target3:GetPosition()) --Set spawn location to pivot 3 player:SetRotation(self.Target3:GetRotation()) --Set spawn rotation to pivot 3 self.counter = self.counter + 1 --Tell the script that player has spawned end end Quote My Games: Nightmare Prism:::WolfTale:::Dungeon Creeper:::Despair of Ordinary Men:::Piano Simulator 2016:::House (W.I.P) Link to comment Share on other sites More sharing options...
f13rce Posted November 11, 2015 Share Posted November 11, 2015 I'm not sure if FPSPlayer has this, but can you try to assign its model and/or camera's position and rotation instead? Quote Using Leadwerks Professional Edition (Beta), mainly using C++. Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz Previously known as Evayr. Link to comment Share on other sites More sharing options...
Einlander Posted November 12, 2015 Share Posted November 12, 2015 Have you tries using the global position and rotation? Quote Link to comment Share on other sites More sharing options...
Angelwolf Posted November 12, 2015 Author Share Posted November 12, 2015 Ok, I have it worked out thanks to the ProjectSaturn youtube tutorial! I needed my script to manipulate the FPSPlayer script, using 'script.camRotation'. Setting this to the pivot rotation worked. Quote My Games: Nightmare Prism:::WolfTale:::Dungeon Creeper:::Despair of Ordinary Men:::Piano Simulator 2016:::House (W.I.P) Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.