OnEnterRegion doesn`t work with animations?

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
SkinnyODST
Lieutenant Colonel
Lieutenant Colonel
Posts: 545
Joined: Mon Jul 04, 2016 10:56 pm
Location: My other account
Contact:

OnEnterRegion doesn`t work with animations?

Post by SkinnyODST »

No matter what I do I can`t seem to get an animation working when I enter a region using the OnEnterRegion function in my LUA. I`m trying this on a world with no other animations.

This is what it looks like, it`s placed right under the FunctionScriptPostLoad
Hidden/Spoiler:
[code]function ScriptPostLoad()

ActivateRegion("animthing")
testfunction = OnEnterRegion(
function(region, player)
if IsCharacterHuman(character) then PlayAnimation ("animthang")
end
end,
"animthing"
) [/code]


animthing = the region that is supposed to trigger the animation

animthang = the animation


I`ve tried a couple different way to set it out like,

PlayAnimation "animthang"

PlayAnimation = "animthang"

and

PlayAnimation = ("animthang") but none have had any effect.
Oh and by the way, I`m trying to animate a rock, "kas2_prop_rock_L"
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: OnEnterRegion doesn`t work with animations?

Post by AnthonyBF2 »

You're using 'player' in the function call but character for the other thing, they need to be the same.

Try:

Code: Select all

ActivateRegion("animthing")
testfunction = OnEnterRegion(
   function(region, character)
      if IsCharacterHuman(character) then PlayAnimation ("animthang")
      end
   end,
"animthing"
) 
ForceMaster
Lieutenant General
Lieutenant General
Posts: 737
Joined: Fri Aug 08, 2008 11:27 pm
Projects :: Tron The Grid
Games I'm Playing :: The best..SWBFII
xbox live or psn: No gamertag set
Location: C:\Program Files\ForceMaster\Bin\ForceMaster.exe

Re: OnEnterRegion doesn`t work with animations?

Post by ForceMaster »

I think you need to use some like this:

ActivateRegion("animthing")
testfunction = OnCharacterEnterRegion(
function(region, character)
if IsCharacterHuman(character) then PlayAnimation ("animthang")
end
end,
"animthing"
)

In these functions the arguments needs to coincide.

Hope help you :wink:
SkinnyODST
Lieutenant Colonel
Lieutenant Colonel
Posts: 545
Joined: Mon Jul 04, 2016 10:56 pm
Location: My other account
Contact:

Re: OnEnterRegion doesn`t work with animations?

Post by SkinnyODST »

Still doesn`t work. However I`ve noticed that if I put something after "On" in "testfunction = OnEnterRegion(" such as "testfunction = OnPlayerEnterRegion(" or "testfunction = OnCharacterEnterRegion(", the AI will not spawn, and the anim still won`t play.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: OnEnterRegion doesn`t work with animations?

Post by Marth8880 »

ForceMaster wrote:I think you need to use some like this:

ActivateRegion("animthing")
testfunction = OnCharacterEnterRegion(
function(region, character)
if IsCharacterHuman(character) then PlayAnimation ("animthang")
end
end,
"animthing"
)

In these functions the arguments needs to coincide.
Nope, it's only OnEnterRegion, as per the documentation. https://sites.google.com/site/swbf2modt ... ing_system

The function's arguments do need to coincide with their references inside the actual function, though, yes. So for example, this would be correct:

Code: Select all

testfunction = OnEnterRegion(
	function(region, player) -- note the argument `character` matches the argument passed to IsCharacterHuman below
		if IsCharacterHuman(character) then PlayAnimation("animthang")
		end
	end,
	"animthing"
)
Whereas this would be incorrect:

Code: Select all

testfunction = OnEnterRegion(
	function(region, player) -- note the argument `player` does not match the argument passed to IsCharacterHuman below
		if IsCharacterHuman(character) then PlayAnimation("animthang")
		end
	end,
	"animthing"
)
Post Reply