SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/03/2018, 11:11 PM   #1
m4karow
Big Clucker
 
Join Date: Oct 2015
Posts: 170
Reputation: 13
Default Smoothly door rotating help needed

Hey there!

I'm started to make a new skin selector system like in singleplayer but i'm close to get a headache becouse i can't rotate the door smoothly. If i add a low value whenever i moving the object, the rotating almost equal with nothing, or it will too fast (i added values less than 0.05). Whenever i add more >= 0.05 to Z the door will move smoothly but it will ugly becouse it's easily to notice if it's height increasing. My second problem is that, whenever OnDynamicObjectMoved called, the object stops for a few ms, and it's also very ugly. I don't know how should i solve this, but i have a few idea, but i need your advices too.

I'd like to create this opening door effect.
https://*********/iJQHtPRXy2I?t=50s

Whenever it's reach its RZ + maybe 65-75 value the object should move a little with a slower speed.
But as i said, whenever the object reachs that value, it will stop for a few ms, and start moving again a little bit.

So if i right i know how to make that you can see on the video, but i dont know how to rotate and sadly i dont have so much time to deal with this problem on my own.
So guys u hope you could help me / know a value which is enough to rotate the object smoothly 😃

Thanks
m4karow is offline   Reply With Quote
Old 21/03/2018, 10:21 AM   #2
PowerMwK
Big Clucker
 
PowerMwK's Avatar
 
Join Date: Sep 2016
Location: Brazil - Ba
Posts: 172
Reputation: 4
Default Re: Smoothly door rotating help needed

Try down 10 percent
__________________
DISCORD DO SERVIDOR:

DISCORD DO TIME DE DESENVOLVIMENTO E CRIAÇÃO:
Desenvolvimento RPG-DM:

PowerMwK is offline   Reply With Quote
Old 22/03/2018, 07:13 PM   #3
m4karow
Big Clucker
 
Join Date: Oct 2015
Posts: 170
Reputation: 13
Default Re: Smoothly door rotating help needed

u mean 0.10? that's too high or what
m4karow is offline   Reply With Quote
Old 22/03/2018, 07:17 PM   #4
PowerMwK
Big Clucker
 
PowerMwK's Avatar
 
Join Date: Sep 2016
Location: Brazil - Ba
Posts: 172
Reputation: 4
Default Re: Smoothly door rotating help needed

type 0.5, you take 10 percent of 0.5 = 0.05 or more high, will testing.
PowerMwK is offline   Reply With Quote
Old 22/03/2018, 07:23 PM   #5
m4karow
Big Clucker
 
Join Date: Oct 2015
Posts: 170
Reputation: 13
Default Re: Smoothly door rotating help needed

oh!
yes, i've tried different values before opened this thread
if i set low value, the door object wont move, just jump from A to B pos
m4karow is offline   Reply With Quote
Old 22/03/2018, 07:24 PM   #6
Maxandmov
Big Clucker
 
Maxandmov's Avatar
 
Join Date: Feb 2011
Location: Moscow, Russia.
Posts: 154
Reputation: 11
Lightbulb Re: Smoothly door rotating help needed

Quote:
Originally Posted by m4karow View Post
oh!
yes, i've tried different values before opened this thread
if i set low value, the door object wont move, just jump from A to B pos
You can, of course, try and make some timer for, let's say, 100 ms and then just basically rotate the door on some calculated angle depending on the iteration done right now. It might not be the best way, but it'll do the trick.
What I mean is, since you can't make the smooth transition between the positions desired, change its position on a slight angle in a small period of time, and it will roughly replicate smooth movement. You can go overhead and actually use it for smooth movement via smaller timers and angles combinations there, too, even - that is, if you want.

And you can reuse such thing for any door later, too.
Maxandmov is offline   Reply With Quote
Old 24/03/2018, 12:45 PM   #7
m4karow
Big Clucker
 
Join Date: Oct 2015
Posts: 170
Reputation: 13
Default Re: Smoothly door rotating help needed

I guessed that i should use timer for this... But it'll be more better if i could do this without it
m4karow is offline   Reply With Quote
Old 24/03/2018, 12:50 PM   #8
Infin1ty
Little Clucker
 
Join Date: Feb 2018
Posts: 25
Reputation: 9
Default Re: Smoothly door rotating help needed

moveobject is the key to what you want to achieve and as the others said
use a shorter time so that it opens slowly
Infin1ty is offline   Reply With Quote
Old 24/03/2018, 12:51 PM   #9
Logic_
High-roller
 
Logic_'s Avatar
 
Join Date: Jun 2015
Location: 666
Posts: 1,493
Reputation: 267
Default Re: Smoothly door rotating help needed

The doors have fixed rotation points and angles, you can't move them oppositely and they will move instantly if done. Show us the code and I'll try to help since I've worked with the door movements previously in my other RP script.
__________________
Premium quality and reasonable pricing game Server hosting
Logic_ is offline   Reply With Quote
Old 24/03/2018, 01:14 PM   #10
m4karow
Big Clucker
 
Join Date: Oct 2015
Posts: 170
Reputation: 13
Default Re: Smoothly door rotating help needed

Now the rotating is fine, but whenever ondynamicobjectmoved called the rotating stops for a few ms... :/

Code:
CreateSkinSelector(2873, 213.87820, -39.86030, 1002.20001, 0.00000, 0, 1);//Suburban
Code:
SkinSelector[selectorid][skinselObject] = CreateDynamicObject(2873, 213.87820, -39.86030, 1002.20001, 0.00000, 0, 1, .streamdistance = 100.0);
Code:
Function:ToggleSkinSelector(selectorid)
{
	if(!SkinSelector[selectorid][skinselUsed])
	{
		SkinSelector[selectorid][skinselMoves] = 1;
		MoveDynamicObject(SkinSelector[selectorid][skinselObject], SkinSelector[selectorid][skinselX], (SkinSelector[selectorid][skinselY] + 0.05), SkinSelector[selectorid][skinselZ], DOOR_MOVING_SPEED, 0.0, 0.0, (SkinSelector[selectorid][skinselA] + 65.0));
	}
}
Code:
public OnDynamicObjectMoved(objectid)
{
	switch(SkinSelector[selectorid][skinselMoves])
	{
		case 1:
		{
			SkinSelector[selectorid][skinselMoves]++;
			MoveDynamicObject(SkinSelector[selectorid][skinselObject], SkinSelector[selectorid][skinselX], SkinSelector[selectorid][skinselY], SkinSelector[selectorid][skinselZ], (DOOR_MOVING_SPEED / 2), 0.0, 0.0, (SkinSelector[selectorid][skinselA] + 5.0));
		}
		case 2:
		{
			SkinSelector[selectorid][skinselMoves]++;
			MoveDynamicObject(SkinSelector[selectorid][skinselObject], SkinSelector[selectorid][skinselX], SkinSelector[selectorid][skinselY] - 0.05, SkinSelector[selectorid][skinselZ], DOOR_MOVING_SPEED, 0.0, 0.0, (SkinSelector[selectorid][skinselA] - 15.0));
		}
		case 3:
		{
			SkinSelector[selectorid][skinselMoves]++;
			MoveDynamicObject(SkinSelector[selectorid][skinselObject], SkinSelector[selectorid][skinselX], SkinSelector[selectorid][skinselY], SkinSelector[selectorid][skinselZ], (DOOR_MOVING_SPEED / 2), 0.0, 0.0, (SkinSelector[selectorid][skinselA] - 5.0));
		}
		case 4:
		{
			SkinSelector[selectorid][skinselMoves]++;
			MoveDynamicObject(SkinSelector[selectorid][skinselObject], SkinSelector[selectorid][skinselX], SkinSelector[selectorid][skinselY] - 0.05, SkinSelector[selectorid][skinselZ], (DOOR_MOVING_SPEED / 2), 0.0, 0.0, (SkinSelector[selectorid][skinselA] + 2.25));
		}
		case 5:
		{
			MoveDynamicObject(SkinSelector[selectorid][skinselObject], SkinSelector[selectorid][skinselX], SkinSelector[selectorid][skinselY], SkinSelector[selectorid][skinselZ], (DOOR_MOVING_SPEED / 2) , 0.0, 0.0, SkinSelector[selectorid][skinselA]);
		}
	}
}
m4karow is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to move a door/open the LSPD door? EtayJ Scripting Help 2 16/11/2016 03:09 AM
Rotating a door. Peter Alex Scripting Help 4 23/07/2012 12:08 AM
[HELP] Rotating door! Larsey123IsMe Help Archive 2 18/11/2010 09:09 PM


All times are GMT. The time now is 05:41 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.