Getting Teleported when you Kill Something [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
asleeponduty
Private First Class
Posts: 77
Joined: Tue Jul 22, 2008 3:05 pm
Games I'm Playing :: AaaaaAAaaaAAAaaAAAA
xbox live or psn: No gamertag set
Location: Illinois

Getting Teleported when you Kill Something [Solved]

Post by asleeponduty »

Could someone with good lua knowledge help me?

In my space map I have tried to set up a teleporter that teleports you when you kill a green barrel.
(Yes I followed Penguins tut just changed a few things)
One small problem. I teleport when I kill anything.
Here is the lua tidbit thats causing me to teleport when I kill stuff :runaway: even the enemy.
Hidden/Spoiler:
OnObjectKill(
function(regIn,character)
MoveEntityToNode(character,"secrethangar")
end,
"greenbarrel"
)
ActivateRegion("secrethangar")

This is a normal teleporter that uses a region
Hidden/Spoiler:
OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"TeleportNode")
end,
"TeleportRegion"
)
ActivateRegion("TeleportRegion")
Note: my other teleporter that uses a region works fine
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Getting Teleported when you kill something problem

Post by Maveritchell »

From the "Everything you need" thread:
http://www.gametoast.com/forums/viewtop ... 27&t=12473
The principle is the same whether you are animating an object or moving an entity.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Getting Teleported when you kill something problem

Post by Fiodis »

Your problem is that you're not checking to see if the object killed is a green barrel or something else. You can do that by taking relative lines from that FAQ tutorial on triggering animations on the destruction of an object.

You also don't need any region, only a target object and a node.
User avatar
asleeponduty
Private First Class
Posts: 77
Joined: Tue Jul 22, 2008 3:05 pm
Games I'm Playing :: AaaaaAAaaaAAAaaAAAA
xbox live or psn: No gamertag set
Location: Illinois

Re: Getting Teleported when you kill something problem

Post by asleeponduty »

So I should have something like this?

OnObjectKill(
function(object, killer)
if killer and GetEntityName(object) "greenbarrel" then
MoveEntityToNode(character,"secrethangar")
end
end
)


Thank you :bowdown:
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Getting Teleported when you kill something problem

Post by Frisbeetarian »

First of all, what is "character" in your code? You can't just use variables that don't exist. It would be more like this:

Code: Select all

OnObjectKill(
function(object, killer)
if GetEntityName(object) == "greenbarrel" then
MoveEntityToNode(killer,"secrethangar")
end
end
)
Assuming you want to teleport anything that destroys the barrel and the barrel never self destructs.
User avatar
asleeponduty
Private First Class
Posts: 77
Joined: Tue Jul 22, 2008 3:05 pm
Games I'm Playing :: AaaaaAAaaaAAAaaAAAA
xbox live or psn: No gamertag set
Location: Illinois

Re: Getting Teleported when you kill something problem

Post by asleeponduty »

Thanks ! :bowdown: It works now
Post Reply