-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTeleport.lua
More file actions
57 lines (44 loc) · 1.73 KB
/
Copy pathTeleport.lua
File metadata and controls
57 lines (44 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- Register the behaviour
behaviour("Teleport")
local instance;
local realPlayer
local particleSystem
function Teleport:Start()
-- Run when behaviour is created
instance = self;
if Player.actor.transform.parent ~= nil then
self.realPlayer = Player.actor.transform.parent
end
self.particleSystem = self.gameObject.GetComponent(ParticleSystem)
if self.gameObject.GetComponent(ParticleSystem) ~= nil then
self.transform.Rotate(-90.0, 0.0, 0.0, Space.Self);
print("ParticleSystem not null")
end
print("[Tp]<color=green>Script Activated!</color>")
print("[Tp]--Teleport-- V9 by Chryses")
print("Press T to teleport")
Overlay.ShowMessage("<color=#18f01c>Script Activated!</color>")
end
function Teleport:Update()
-- Run every frame
if instance ~= self then
return
end
if Player.actor.transform.parent ~= nil then
self.realPlayer = Player.actor.transform.parent
end
if Input.GetKeyDown(KeyCode.T) then
--Overlay.ShowMessage("<color=#34abeb>Switched</color>")
local ray = Ray(PlayerCamera.activeCamera.main.transform.position + PlayerCamera.activeCamera.main.transform.forward * 1, PlayerCamera.activeCamera.main.transform.forward)
local raycast = Physics.Raycast(ray,1190, RaycastTarget.ProjectileHit)
if raycast ~= nil then -- C# raycast != null
print("Raycast hit : " .. raycast.point.ToString())
self.particleSystem.transform.position = self.realPlayer.position
self.transform.Rotate(0, self.realPlayer.localRotation.y, 0.0, Space.Self);
self.particleSystem.Simulate( 0.0, true, true )
self.particleSystem.Play();
self.realPlayer.position = raycast.point - PlayerCamera.activeCamera.main.transform.forward
--print("Collider " .. tostring(raycast.collider))
end
end
end