Obracanie obiektu wokół własnej osi

Uczymy się edytowania P2 i rozwiązujemy nasze problemy. Nowi adepci mile widziani!

Moderatorzy: Moderatorzy, Admini

Awatar użytkownika
seebeek17
Modder
Modder
Posty: 8399
Rejestracja: 10 cze 2013, 13:25
Lokalizacja: Z Zewnątrz
Kontakt:

16 sie 2017, 22:00

Pomoże mi ktoś w tym?
Chcę żeby StaticMesh w klasie Attachment mojej broni, kręcił się wokół własnej osi.
Próbowałem już wiele sposobów i używałem setki funkcji (UpdatePawnAttachment(), UpdateRotation(), SetRelativeRotation(), SetRotation(), itp. ), i nadal to cholerstwo nie działa. :/

Chciałem to kontrolować jedną funkcją w klasie MyWeapon.uc mojej broni:

Kod: Zaznacz cały

function Tick(float DeltaTime)
{
   local float deltaRotation;
   local Rotator newRotation;
   local string rotLog;
   
   deltaRotation = SvelRotation * DeltaTime; 
   
   newRotation = Rotation;
   
   newRotation.Pitch += deltaRotation;
   newRotation.Yaw  += deltaRotation;   
   newRotation.Roll  += deltaRotation;     
   
	//if(sAttachment!=None)
	//{
		// sAttachment.bIgnoreBaseRotation=true; // Does not working
		sAttachment.SetRelativeRotation(newRotation);
		sAttachment.UpdatePawnAttachment(false);
	//}
	
	// For testing is function working good
	rotLog = sAttachment.RelativeRotation.Roll@sAttachment.RelativeRotation.Yaw@sAttachment.RelativeRotation.Pitch;
	Instigator.ClientMessage("Rotation: "@rotLog);
}
P2Attachment to najdziwniej zrobiona klasa w Postalu 2.

Zna ktoś jakiś sposób, żeby obracać StaticMesh z klasy Attachment wokół własnej osi?


Awatar użytkownika
EvilT-ModZ
Modder
Modder
Posty: 159
Rejestracja: 16 sie 2010, 17:30

17 sie 2017, 21:03

Kod: Zaznacz cały

    //if(sAttachment!=None)
    //{
        // sAttachment.bIgnoreBaseRotation=true; // Does not working

		///first of all if you uses SetRelativeRotation you have to be sure sAttachment is based somewhere, PawnOwner is an example
		sAttachment.SetBase(PawnOwner);

        sAttachment.SetRelativeRotation(newRotation);
        sAttachment.UpdatePawnAttachment(false);/// has not effect at all, used to force animations, etc
    //}


Awatar użytkownika
seebeek17
Modder
Modder
Posty: 8399
Rejestracja: 10 cze 2013, 13:25
Lokalizacja: Z Zewnątrz
Kontakt:

21 sie 2017, 23:20

Thanks! That's working now!

But I have next problem. :/

StaticMesh (in weapon Attachment) already rotating around Dude's hand.
I wish the StaticMesh rotating around himself (like tire in a car).

Do you know how to hmm... set pivot location in a attachment's Static Mesh?
I think bad pivot location is a problem


ODPOWIEDZ