Jump to content

Spawning


Angelwolf
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

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

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

Link to comment
Share on other sites

I'm not sure if FPSPlayer has this, but can you try to assign its model and/or camera's position and rotation instead?

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...