Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

[SA] Object angle based on target position


In45do
 Share

Recommended Posts

I'm having a hard time how to make object looking at target position. Can someone tell me step by step to make it happen?

Link to comment
Share on other sites

Let say my target is a vehicle with its x,y,z coord and I have my object randomly placed.

 

How do I make this object to look at vehicle coordinates? I was thinking to use opcode 0177 to set my object's angle but I don't know how to convert vehicle's position into angle variable.

Do you have an alternative way to make it happen?

Link to comment
Share on other sites

00AA: store_car [email protected] position_to [email protected] [email protected] [email protected]
0604: get_Z_angle_for_point [email protected] [email protected] store_to [email protected]
0177: set_object [email protected] Z_angle_to [email protected]

Am I doing it right? It's changing angle but it doesn't looking at the target.

Link to comment
Share on other sites

be more specific what you want

the way you showing this part of your script 

this is the way it should be

 

0174: [email protected] = car [email protected] Z_angle
0177: set_object [email protected] Z_angle_to [email protected]

 

if it is not what you looking for .. then ask me i have other way to set object the way you want 

Edited by Strs
clarifying
Link to comment
Share on other sites

It basically copying target angle into object angle. The way I want it is to make this object looking at target position.

Link to comment
Share on other sites

target target what target ? you are the one who targeting some one or somewhere or some one targeting you ? be more specific you trying to make missile mod ?

if yes ill give you whole script and you can edit or do what ever you want to do

https://youtu.be/URa2ch1lXk0

Link to comment
Share on other sites

On 10/26/2018 at 10:16 AM, In45do said:
00AA: store_car 0@ position_to 1@ 2@ 3@
0604: get_Z_angle_for_point 1@ 2@ store_to 3@
0177: set_object 4@ Z_angle_to 3@

Am I doing it right?

No.

To calculate an angle requires 2 points (4 coords), x,y of object and x,y of car

But you can enter only 1 point (2 coords) to opcode 0604: get_Z_angle

So what do we need to do?

We need to bring the constellation in relation to the game center 0.0

 

subtract car_position from car_position = 0.0

subtract car_position from object_position = 2 coords for opcode 0604: get_Z_angle

 

test the script below, consider that it use player position instead car position

 

{$CLEO .cs}
:Object_rotate
thread 'OBJROT'

// 1581, keycard, 

while true
wait 0
    if
        0256: player $PLAYER_CHAR defined
    then
        if
            0AB0:   key_pressed 8//-----------------------press Backspace
        then
            0247: request_model 1581
            038B: load_requested_models 
            04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset 0.0 3.5 0.0
            0107: 0@ = create_object 1581 at  11@ 12@ 13@

            while 0256: player $PLAYER_CHAR defined
                wait 0
                04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset 0.0 0.0 0.0
                0400: store_coords_to 21@ 22@ 23@ from_object 0@ with_offset 0.0 0.0 0.0
                0063: 21@ -= 11@ // (float) 
                0063: 22@ -= 12@ // (float) 
                0604: get_Z_angle_for_point 21@ 22@ store_to 30@
                0453: object 0@ set_rotation  0.0  0.0 30@
                if  or
                    8474:   not actor $PLAYER_ACTOR near_object_in_cube 0@ radius 100.0 100.0 100.0 flag 0
                    0AB0:   key_pressed 48// ------------ 	0 key
                then
                    break
                end
            
            end
            0108: destroy_object 0@
        end
    end
end

 

Edited by ZAZ
Link to comment
Share on other sites

It worked, thanks alot ZAZ! It's direction was flipped so I added 180.0 and it finally facing the target. Although I don't understand why did you add [email protected] = 0.0 in that script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.