Jump to content

Recommended Posts

18 hours ago, drecalen said:

hi, im working on my own character mod, and im importing my sona.

however, i know about sprite flipping and i know that doesnt go over well with asymmetrical characters. 

how to i fix this, if possible?

I will assume your sona is your icon?

which if so, then I have an easy solution for that

What you need to do first, is to duplicate its build and separate it by folders, example:
 mychar_right
mychar_left

In it you will add the differences to the head, accordingly where it is, left or right. Note however, that doing it with arms or legs doesn't really work well, as it will replace both legs or arms depending on the side it is facing.

Then in your character prefab master_postinit, add the both anims example:

local assets = {
 Asset( "ANIM", "anim/mychar_right.zip" ),
 Asset( "ANIM", "anim/mychar_left.zip" ),

}

then in the master_postinit

 

  inst:ListenForEvent("locomote", function(inst)   
  if inst:HasTag("playerghost") then 
  return end    
  local dir = inst.Transform:GetRotation()   
  local camera_rot = TheCamera:GetHeadingTarget()    
  print("Camera rotation:", camera_rot)   
  print("Direction:", dir)   
  if camera_rot < 0 then     
  camera_rot = camera_rot + 360    
  end          
  if camera_rot == 0 or camera_rot == 45 then   
  if dir <= 0 then   
  inst.AnimState:SetBuild("mychar_right")    
  else        
  inst.AnimState:SetBuild("mychar_left")  
  end      
  elseif camera_rot == 90 or camera_rot == 135 then  
  if math.abs(dir) >= 90 then    
  inst.AnimState:SetBuild("mychar_right")     
  else         
  inst.AnimState:SetBuild("mychar_left")   
  end     
  elseif camera_rot == 180 or camera_rot == 225 then       
  if dir >= 0 then     
  inst.AnimState:SetBuild("mychar_right")  
  else         
  inst.AnimState:SetBuild("mychar_left")   
  end     
  else--if camera_rot == 270 or camera_rot == 315 then  
  if math.abs(dir) <= 90 then  
  inst.AnimState:SetBuild("mychar_right")    
  else            
  inst.AnimState:SetBuild("mychar_left")   
  end    
  end  
  end)

compile the two builds and run the game and see if the changes works.

1 hour ago, halfrose said:

I will assume your sona is your icon?

which if so, then I have an easy solution for that

What you need to do first, is to duplicate its build and separate it by folders, example:
 mychar_right
mychar_left

In it you will add the differences to the head, accordingly where it is, left or right. Note however, that doing it with arms or legs doesn't really work well, as it will replace both legs or arms depending on the side it is facing.

Then in your character prefab master_postinit, add the both anims example:


local assets = {
 Asset( "ANIM", "anim/mychar_right.zip" ),
 Asset( "ANIM", "anim/mychar_left.zip" ),

}

then in the master_postinit

 


--snip--

compile the two builds and run the game and see if the changes works.

a simpler version:

inst:ListenForEvent("locomote", function()
	if inst:HasTag("playerghost") then 
		return 
	end
	if inst.AnimState:GetCurrentFacing() == 2 then 
		inst.AnimState:SetBuild("mychar") -- left animation
	elseif inst.AnimState:GetCurrentFacing() == 0 then 
		inst.AnimState:SetBuild("mychar_right") -- right animation
	end
end)

 

Edited by Aquaterion
On 10/19/2016 at 9:34 PM, halfrose said:

the character prefab, it is where you can find the master_postinit. if that is what you are asking.

ok, just a little bug, i already have a transform code in here, relying on sanity levels. how do i code it so it still does the left/right in each form?

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...