Object collision
#1

Hello.

I was wondering if anyone got a way to detect collision between 2 objects.
(ex.: Detect when a rocket (an object) hits a wall)
Any ideas are welcomed.

Thanks in advance.
Reply
#2

Bump. Impossible?
Reply
#3

Only if you know the coordinates for the end object, otherwise I don't think there is a function for it as far as I know. GetObjectPos/GetDynamicObjectPos exists to get object X, Y, Z.

In this simple video I used MapAndreas (I think it was that one, unless I confused it with ColAndreas something) and hence knowing the vector point of where the objects will "hit the ground" by the given X and Y:
https://www.youtube.com/watch?v=7mSrSaWzqg0
Reply
#4

Use colandreas. It is designed for collisions. Look at its name Collision Andreas.
Reply
#5

Quote:
Originally Posted by coool
View Post
Use colandreas. It is designed for collisions. Look at its name Collision Andreas.
agreed MapAndreas detect only san andreas map collision ColAndreas detect any collision so if you created map it will detect it too MapAndreas wont
Reply
#6

Quote:
Originally Posted by coool
View Post
Use colandreas. It is designed for collisions. Look at its name Collision Andreas.
You mean this? https://sampforum.blast.hk/showthread.php?tid=586068
I still can't understand how can I use one of those functions to detect what I wrote.
Reply
#7

Because they are silly and didn't actually read what you wrote, instead they took the context of my post and thought it was the main post, for some reason. Anyways I just gave an example and I still hold what I said.

There's no magical function (at least not without a plugin) and only way to get it is through knowing the end coordinates as I repeat again. My example only showed the way to get when an object collides with the ground (Z).
Reply
#8

Like Hansrutger said, you need to know the end position, everything else would be to computationally intensive in pawn
For example, your rocket, whenever you call MoveObject calculate beforehand the next collision with CA_RayCastLine and adjust the destination
Reply
#9

What's the path of that rocket?

If it's a non-homing rocket which travels a straight line, just use CA_RayCastLine once and you know the end position.

For more complex paths (eg homing rocket with moving target, like a vehicle) it's almost the same, just that you have to raycast for every change in direction that the rocket does.

CA uses way less resources than you think. A 5000 Node 3D Path can be checked for collisions within a few ms (using raycasting), and I seriously doubt any Rocket will fly that far. If the target is moving it has to check only once every few ms anyway.
Reply
#10

Quote:
Originally Posted by Hansrutger
View Post
Because they are silly and didn't actually read what you wrote, instead they took the context of my post and thought it was the main post, for some reason. Anyways I just gave an example and I still hold what I said.

There's no magical function (at least not without a plugin) and only way to get it is through knowing the end coordinates as I repeat again. My example only showed the way to get when an object collides with the ground (Z).
Quote:
Originally Posted by Nero_3D
View Post
Like Hansrutger said, you need to know the end position, everything else would be to computationally intensive in pawn
For example, your rocket, whenever you call MoveObject calculate beforehand the next collision with CA_RayCastLine and adjust the destination
Quote:
Originally Posted by NaS
View Post
What's the path of that rocket?

If it's a non-homing rocket which travels a straight line, just use CA_RayCastLine once and you know the end position.

For more complex paths (eg homing rocket with moving target, like a vehicle) it's almost the same, just that you have to raycast for every change in direction that the rocket does.

CA uses way less resources than you think. A 5000 Node 3D Path can be checked for collisions within a few ms (using raycasting), and I seriously doubt any Rocket will fly that far. If the target is moving it has to check only once every few ms anyway.
Thank you!
So basically it is a rocket moving by MoveObject (non-homing). I got the ending position, now am I using just CA_RayCastLine to know if it collides with other objects?
Reply
#11

Quote:
Originally Posted by ranme15
Посмотреть сообщение
Thank you!
So basically it is a rocket moving by MoveObject (non-homing). I got the ending position, now am I using just CA_RayCastLine to know if it collides with other objects?
Correct. You fill in start and end coords, pass it a set of 3 variables to store the hit point in and save the return value as well to determine if it was a hit or not. It will return 0 if it didn't hit anything, 20000 for Water and otherwise the Model ID.
Technically, you can just use the Hit Point as destination and make it explode there if something was hit. Otherwise use the destination as end point.

If you want mappings etc to be considered as well, use CA_CreateObject (additionally to CreateDynamicObject) - or use the DC Object functions (which handles both Collision and Streamer Objects). It's described pretty well in the Include as well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)