View Full Version : Spawn Model in front of player
Loveboy
21st February 2014, 21:07
Hello Guys
I want to spawn a model in front of player, but I have got a problem.
The angles are not the problem, they are showing the same angles like the player (mode.angles = playerangles)
The problem is, I want to spawn a model, which is in front of the player, but it doesn't work.
I tried to do the origin of the player [X] + 30 (doesn't worked), then [Y] + 30 (doesn't worked too) and [Z] will go up.
Here is a picture what describes what I mean:
646
I hope you can help me in this :)
Thank you!
Tally
21st February 2014, 21:41
model = spawn( "script_model", self.origin + maps\mp\_utility::vectorScale( anglesToForward( self.angles ), 50 ) ); // 50 is the distance in front of you. Increase or decrease it depending on how far or near you want the model
Loveboy
21st February 2014, 22:13
Hmm It still does not work correctly :(
Here the script:
sentrygun_stand = spawn("script_model", self.origin + maps\mp\_utility::vectorScale(anglesToForward(self .origin), 50));
sentrygun_stand setModel("xmodel/sentrygun_stand");
sentrygun_stand.angles = (int(self.angles[0]), int(self.angles[1]), 0);
sentrygun_gun = spawn("script_model", self.origin + (0, 0, 47) + maps\mp\_utility::vectorScale(anglesToForward(self .origin), 50));
sentrygun_gun setModel("xmodel/sentrygun_gun");
sentrygun_gun.angles = (int(self.angles[0]), int(self.angles[1]), 0);
How it does look ingame:
647
Tally
21st February 2014, 22:26
It appears your sentry_stand model has its origin off-centre. And because it is off-centre, you are going to have to re-position the origin in Maya/Blender so that it is perfectly centred.
Or, you can off-set the player origin to compensate for the model's off-centre:
origin = ( self.origin + ( 0, -30, 0 ) );
model = spawn( "script_model", origin + maps\mp\_utility::vectorScale( anglesToForward( self.angles ), 50 ) );
(0,-30,0) is just an example. You will need to play around with it to see which works best. I have no idea which direction you will need to move the off-set because I don't have your model to test with, and so I can't actually show you.
Please do not post back and say "It still isn't working". No one can make it work for you. You are going to have to test, and test, and test again. And if you can't do it by script, you really are going to have to re-position the point of origin in the models.
serthy
21st February 2014, 22:32
sentrygun_stand = spawn("script_model", self.origin + maps\mp\_utility::vectorScale(anglesToForward(self .origin), 50));
should'nt this be either self getPlayerAngles() or self.angles - like Tally said (I was too slow)?
Loveboy
21st February 2014, 22:37
This sentrygun has got two models, so the gun will only move. I want that the player can see something while he is seaching for a place, where he can place his sentry gun. So the sentrygun should be a bit in the front of him, not in his origin.
Like in this picture (click [or copy and paste] on the link to see the picture): http://img.youtube.com/vi/NjfZdjk0O_o/0.jpg
Surely the models are in the middle:
648
649
Tally
21st February 2014, 22:38
should'nt this be either self getPlayerAngles() or self.angles - like Tally said (I was too slow)?
Well spotted! That's why the model is off-centre: because he is vectoring the origin again, instead of the angles.
this is what it should be:
sentrygun_stand = spawn("script_model", self.origin + maps\mp\_utility::vectorScale(anglesToForward(self .angles), 50));
sentrygun_stand setModel("xmodel/sentrygun_stand");
sentrygun_stand.angles = (int(self.angles[0]), int(self.angles[1]), 0);
sentrygun_gun = spawn("script_model", self.origin + (0, 0, 47) + maps\mp\_utility::vectorScale(anglesToForward(self .angles), 50));
sentrygun_gun setModel("xmodel/sentrygun_gun");
sentrygun_gun.angles = (int(self.angles[0]), int(self.angles[1]), 0);
I wish people would learn to READ!!!!! Saves people a lot of bother.
Loveboy
21st February 2014, 22:53
Works fine, thank you Tally!
650
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.