Announcement

Collapse
No announcement yet.

Change spawn and direction of spawned missiles

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change spawn and direction of spawned missiles

    I want to make missiles spawn a little bit to the right because I replaced the rocket launcher model and it's not centered.

    I went to this function in weapons.qc:

    Code:
    void() W_FireRocket

    More specifically here:

    Code:
    setorigin (missile, self.origin + v_forward*8 + '0 0 16');

    And changed those last three values with more or less positive results. The problem is that because it takes into account self.origin, when the player rotates around, the spawning point for the missile also changes.

    I also tried changing self.origin for self.weaponmodel.origin (in an attempt to use the weapon model itself as the origin to start the v_forward from) but it doesn't compute.

    This looks like a recurrent modification so I'm sure there's an easy and well researched answer somewhere in here. Browsed the forums for some time but couldn't find this info. Any help appreciated!






  • #2
    Hello woxerz,

    Originally posted by woxerz View Post
    I want to make missiles spawn a little bit to the right because I replaced the rocket launcher model and it's not centered.

    I went to this function in weapons.qc:
    Code:
    void() W_FireRocket

    More specifically here:
    Code:
    setorigin (missile, self.origin + v_forward*8 + '0 0 16');
    Yes, that is exactly the right spot to look at and edit.



    Originally posted by woxerz View Post
    And changed those last three values with more or less positive results. The problem is that because it takes into account self.origin, when the player rotates around, the spawning point for the missile also changes.
    If it would not take self.origin into account, it would never stick to the player.
    The problem you describe is because you are using a fixed vector, which does NOT take the player view angle into account.
    This makes only sense for the z value. As soon as you are using fixed x and y values you will be screwed.
    So, best is to get rid of that vector once and for all.
    You have to make a different approach:
    use v_forward, v_right and v_up together with .view_ofs instead.
    That way your vector will always follow your view angle. That is what you was aiming for.



    Originally posted by woxerz View Post
    I also tried changing self.origin for self.weaponmodel.origin (in an attempt to use the weapon model itself as the origin to start the v_forward from) but it doesn't compute.
    Moving the weapon model around doesnt make the projectiles follow it automagically. Both are completely independent and follow different code.


    Originally posted by woxerz View Post
    This looks like a recurrent modification so I'm sure there's an easy and well researched answer somewhere in here. Browsed the forums for some time but couldn't find this info. Any help appreciated!
    Nah, cīmon. You surely didnt browse through this forum enough.
    Everything you need is already here.
    For example here you will find the source code to do what you are aiming for.
    It is directly there in the mods section.

    If you want to go beyond this forum, you should visit the biggest website with QuakeC tutorials here

    I am sure you will now be able to do it yourself.
    If you have further questions, fell free to ask.

    Best wishes,
    Seven

    Comment


    • #3
      What I meant was using the weapon model origin to at least solve the issue of spawning the projectile a little bit to the right, and change direction later somehow

      Code:
      use v_forward, v_right and v_up together with .view_ofs instead.
      This did it.

      Thanks Seven!

      Comment

      Working...
      X