Results 1 to 8 of 8

Thread: Spawn Model in front of player

  1. #1
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts

    Spawn Model in front of player

    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:
    Click image for larger version. 

Name:	pic1.png 
Views:	44 
Size:	4.2 KB 
ID:	646

    I hope you can help me in this

    Thank you!

  2. #2
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    PHP Code:
    model spawn"script_model"self.origin maps\mp\_utility::vectorScaleanglesToForwardself.angles ), 50 ) ); // 50 is the distance in front of you. Increase or decrease it depending on how far or near you want the model 

  3. The Following 2 Users Say Thank You to Tally For This Useful Post:

    Loveboy (21st February 2014),Ni3ls (22nd February 2014)

  4. #3
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Hmm It still does not work correctly

    Here the script:
    Code:
    	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:
    Click image for larger version. 

Name:	fail.png 
Views:	51 
Size:	1.29 MB 
ID:	647

  5. #4
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    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:

    PHP Code:
    origin = ( self.origin + ( 0, -30) );
    model spawn"script_model"origin maps\mp\_utility::vectorScaleanglesToForwardself.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.
    Last edited by Tally; 21st February 2014 at 21:36.

  6. The Following User Says Thank You to Tally For This Useful Post:

    kung foo man (21st February 2014)

  7. #5
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    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)?

  8. The Following User Says Thank You to serthy For This Useful Post:

    kung foo man (21st February 2014)

  9. #6
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    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:
    Click image for larger version. 

Name:	stand.png 
Views:	40 
Size:	244.6 KB 
ID:	648

    Click image for larger version. 

Name:	gun.png 
Views:	40 
Size:	241.2 KB 
ID:	649

  10. #7
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by serthy View Post
    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:

    PHP Code:
        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 + (0047) + 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.

  11. The Following User Says Thank You to Tally For This Useful Post:

    Loveboy (21st February 2014)

  12. #8
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Works fine, thank you Tally!

    Click image for larger version. 

Name:	view.png 
Views:	51 
Size:	1.03 MB 
ID:	650

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •