Rotating smashbar
#1

Hey

How I could rotate the smashbar (model id 1251) smoothly? For example whenever the train comes and the barrier goes up / down? I know the required function I just need the values, becouse whenever I create an object at closed position and create an opened too and move the object from closed to open the rotating is so ugly.
Reply
#2

bump
Reply
#3

Код:
stock IsVehicleInObjectRangePoint(vehicleid,objectid,Float:x,Float:y,Float:z)
{
    GetVehiclePos(vehicleid,Float:x,Float:y,Float:z);
    GetObjectPos(objectid,Float:x,Float:y,Float:z);
}
/*public function*/{
new Float:x,Float:y,Float:z;
IsVehicleInObjectRangePoint(vehicleid,objectid,Float:x + 1 ^ - 1,Float:y + 1 ^ - 1,Float:z + 1 ^ - 1);
{
   MoveObject(/*smashbar*/,Float:x,Float:Y,Float:z + 1);
   if(IsObjectMoving(objectid) && StopObject(/*smashbar*/)
{
    MoveObject(/*smashbar*/,Float:x,Float:y,Float:z - 1);
}
}
return 0; //not certain
}
Still try.
Reply
#4

Did you read my post? Or just replying to the thread title?
Reply
#5

Can you post video or post pictures what's happening ?

And post codes of OPEN and CLOSE barrier.
Reply
#6

Quote:
Originally Posted by m4karow
Посмотреть сообщение
Did you read my post? Or just replying to the thread title?
I am not examination object model and how you do realistic smashbar effect because high probably you not waiting effect very hard or use setobjectpos.
Reply
#7

Код:
#include "a_samp.inc"
#include "a_vehicles.inc"
#include "a_objects.inc"

stock IsVehicleInObjectRangePoint(vehicleid,objectid,Float:x,Float:y,Float:z)
{
    GetVehiclePos(vehicleid,Float:x,Float:y,Float:z);
    GetObjectPos(objectid,Float:x,Float:y,Float:z);
}
foward OnVehicleModel(vehicleid);
public OnVehicleModel(vehicleid){
new Float:x,Float:y,Float:z, Float:rx, Float:ry, Float:rz;
switch(vehicleid)
{
	case 1:537;
	case 2:538;
	case 3:570;
	case 4:590;
	case 5:569;
}
if(IsVehicleInObjectRangePoint(vehicleid,1251,Float:x + 1 >= 0.1,Float:y + 1 >= 0.1,Float:z))
{
   MoveObject(1251,Float:x,Float:y,Float:z, Float:rx, Float:ry, Float:rz + 11);
   {
	   if(rx == rz)
	   {
		 SetObjectPos(1251,x + 5.5, y + 5.5, z + 5.5);
       }
	}
   if(IsObjectMoving(1251) == false && IsVehicleInObjectRangePoint(vehicleid,1251,Float:x + 1 >= 0.1,Float:y + 1 >= 0.1,Float:z))
{
    MoveObject(1251,Float:x,Float:y,Float:z, rx, ry, rz - 11);
    if(rx == rz)
	   {
		 SetObjectPos(1251,x - 5.5, y - 5.5, z - 5.5);//other functions for not have time
       }

}
}
return 0; //not certain
}
but have a errors
Код:
C:\samp server\pawno\smashbar.pwn(10) : error 010: invalid function or declaration
C:\samp server\pawno\smashbar.pwn(11) : warning 235: public function lacks forward declaration (symbol "OnVehicleModel")
C:\samp server\pawno\smashbar.pwn(15) : warning 215: expression has no effect
C:\samp server\pawno\smashbar.pwn(16) : warning 215: expression has no effect
C:\samp server\pawno\smashbar.pwn(17) : warning 215: expression has no effect
C:\samp server\pawno\smashbar.pwn(18) : warning 215: expression has no effect
C:\samp server\pawno\smashbar.pwn(19) : warning 215: expression has no effect
C:\samp server\pawno\smashbar.pwn(21) : warning 213: tag mismatch
C:\samp server\pawno\smashbar.pwn(21) : warning 213: tag mismatch
C:\samp server\pawno\smashbar.pwn(21) : warning 209: function "IsVehicleInObjectRangePoint" should return a value
C:\samp server\pawno\smashbar.pwn(30) : warning 213: tag mismatch
C:\samp server\pawno\smashbar.pwn(30) : warning 213: tag mismatch
C:\samp server\pawno\smashbar.pwn(30) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#8

Well, I remember I did a similar thing once with another object.

Object definition
PHP код:
bar1=CreateDynamicObject(968997.431211708.6524710.65440,   0.0000090.0000090.00000); 
/open
PHP код:
MoveDynamicObject(bar1,997.431211708.6524710.65440+0.010.01,  0.000000.0000090.00000); 
/close
PHP код:
MoveDynamicObject(bar1,997.431211708.6524710.65440-0.010.010.0000090.0000090.00000); 
As you can see I modified the Z coords in a minimal way just to let the object start moving, then I put a really slow speed and I rotated the rot:Y coord. Try to do something similar, I'm sure it will help you
Reply
#9

Quote:
Originally Posted by ReshiramZekrom
Посмотреть сообщение
Well, I remember I did a similar thing once with another object.

Object definition
PHP код:
bar1=CreateDynamicObject(968997.431211708.6524710.65440,   0.0000090.0000090.00000); 
/open
PHP код:
MoveDynamicObject(bar1,997.431211708.6524710.65440+0.010.01,  0.000000.0000090.00000); 
/close
PHP код:
MoveDynamicObject(bar1,997.431211708.6524710.65440-0.010.010.0000090.0000090.00000); 
As you can see I modified the Z coords in a minimal way just to let the object start moving, then I put a really slow speed and I rotated the rot:Y coord. Try to do something similar, I'm sure it will help you
Yes more realistic and I think run.
Reply
#10

If I want to rotate that bar I have to change the Z, and the X (or Y) position of the bar, becouse it moving

First, the closed position


I've changed the RX position - You can see, the bar moved low


I've added +2 to Z. You can see, the bar moved forward.
Reply
#11

That's because the 'pivot point' of the object is in the centre of it, not on the side that you want it to pivot from. So if you rotate it, it's rotating from the centre of the object, not the end of it.

To accommodate for this, you just need to adjust the X, Y and Z values until it looks like the desired open position that you want..

Some helpful callbacks/functions:
https://sampwiki.blast.hk/wiki/MoveObject
https://sampwiki.blast.hk/wiki/OnObjectMoved
Reply
#12

Quote:
Originally Posted by Threshold
Посмотреть сообщение
That's because the 'pivot point' of the object is in the centre of it, not on the side that you want it to pivot from. So if you rotate it, it's rotating from the centre of the object, not the end of it.

To accommodate for this, you just need to adjust the X, Y and Z values until it looks like the desired open position that you want..

Some helpful callbacks/functions:
https://sampwiki.blast.hk/wiki/MoveObject
https://sampwiki.blast.hk/wiki/OnObjectMoved
Yes I did that but it's still rotating ugly.
It moving highter then it goes down... I'd like to rotate the smashbar like whenever a train left the crain crossing then the bar goes up. Could you give me any advice to do that?
Reply
#13

There's nothing more you can do other than play with the coordinates or change the way it moves until it looks right.
Reply
#14

That’s what I afraid of...
Reply
#15

Quote:
Originally Posted by m4karow
Посмотреть сообщение
Yes I did that but it's still rotating ugly.
It moving highter then it goes down... I'd like to rotate the smashbar like whenever a train left the crain crossing then the bar goes up. Could you give me any advice to do that?
Why smashbar?
Reply
#16

Quote:
Originally Posted by m4karow
Посмотреть сообщение
That’s what I afraid of...
Just place it where it should be in the first position, then in the second position using a Map Editor.
Then use the coords and rotations from those two objects. It's really that simple!
Reply
#17

Quote:
Originally Posted by NaS
Посмотреть сообщение
Just place it where it should be in the first position, then in the second position using a Map Editor.
Then use the coords and rotations from those two objects. It's really that simple!
You are wrong. Check my older post
Reply
#18

https://www.youtube.com/watch?v=CcJ1VCipcnY

Needs a bit more tweaking (on the Y axis) so that the right end doesn't move anymore but other than that it works. You could even hide the right end of the bar inside the stand that holds it, so it wouldn't be visible.

That's about the best it gets though. The path the pivot takes is linear, however for a 100% perfect movement it had to be a curve. You could only achieve that with more than 1 move to get as close as possible to a curve.

Otherwise there are several other objects with a more convenient pivot point you could use. Retexturing is possible too if it's the look you want.
Alternatively attach it to 19300 and rotate that one instead (although that shouldn't be neccessary and requires YSF/pawn.raknet).
Reply
#19

Quote:
Originally Posted by NaS
Посмотреть сообщение
https://www.youtube.com/watch?v=CcJ1VCipcnY

Needs a bit more tweaking (on the Y axis) so that the right end doesn't move anymore but other than that it works. You could even hide the right end of the bar inside the stand that holds it, so it wouldn't be visible.

That's about the best it gets though. The path the pivot takes is linear, however for a 100% perfect movement it had to be a curve. You could only achieve that with more than 1 move to get as close as possible to a curve.

Otherwise there are several other objects with a more convenient pivot point you could use. Retexturing is possible too if it's the look you want.
Alternatively attach it to 19300 and rotate that one instead (although that shouldn't be neccessary and requires YSF/pawn.raknet).
That's how mine moving. (Your's better a bit. )
Then I'll try. Thanks
Reply
#20

It looks like you need the rotation to occur at a different speed to the position, which you cannot possibly do with a single MoveObject command.. I suggest you look for a different object.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)