Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Making a static collision box

Author
Message
SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 7th Feb 2013 17:26
Hello,

So, I am having problems with making the static collision box. I've spent numerous days trying to figure out what the problem is with no luck at all. Can anyone help?



-Sa
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 7th Feb 2013 20:10
What exactly is the issue? Looks like the collision box is set up correctly. Are you doing any collision checking when moving the object around?

SET GLOBAL COLLISION ON to turn on collision.
SET OBJECT COLLISION ON for the object.
return = OBJECT COLLISION for the check.

You may want to look into Sparky's Collision dll. It's got some pretty handy features and I think it runs much faster than DBP's collision.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 8th Feb 2013 17:38
Ok.
So I tried your suggestion, but I'm still having other objects go straight through it.
Basically what I am trying to do is make it so that if the character (object 1 in the code below) bumps into the box (the aforementioned object 8), then the screen clears and text shows up. I have added all of the code that relates to that below. Any ideas?











-Sa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 8th Feb 2013 20:00 Edited at: 12th Feb 2013 22:50
[EDITED] I noticed you're moving your object a distance of 12000

This means your object is probably entirely 'skipping past' the object(s) it's supposed to collide with.

You may want to try using INTERSECT OBJECT.

D.D.
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 9th Feb 2013 01:43 Edited at: 9th Feb 2013 01:51
I think SET OBJECT SPEED only affects how fast the animation of the object plays. But, do be aware of what Mr. Darkly said; if an object moves too far in one step, it might miss the collision completely. Moving an object doesn't smoothly 'move' it. It 'teleports' it to it's new destination. (so to speak)


I think the issue may be that you are not setting up ALL objects for collision. You will need to SET OBJECT COLLISION ON for each object you want collision detection for.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 11th Feb 2013 17:21
@Derek Darkly,
How should I use the intersect object command?
(I'm still a Half-rookie at this)

Also, I don't think the object speed is making a difference because my game moves the object forward 4.5 when I press the arrow keys. (I tried reducing that number with the same results.)

Thank you!

-Sa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 11th Feb 2013 20:14 Edited at: 14th Feb 2013 19:29
[SNIP] see below.

D.D.
SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 12th Feb 2013 17:28

Ok... I'm still confused...
Am I doing this right?
(Sorry for all these questions upon questions)
I want it to display a question on screen when and only when the man(object 1) hits the totem (object 8).



Here is the code for making the totem, if it helps.


-Sa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 12th Feb 2013 18:32 Edited at: 14th Feb 2013 21:37
2 things:

(1) Use 8 instead of 1 in your INTERSECT OBJECT, since 8 is the target, not 1.

(2) You'll want to get your moving object's next position rather than using the coordinates of the Totem as the end of your line. The reason is that if your object moves too far past the Totem in a single move it won't register a hit.


[SNIP]

D.D.
SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 14th Feb 2013 17:08
Umm...
Ok, for some reason my IF INTERSECT OBJECT command just doesn't seem to work.

Is there any way I could use something like a IF OBJECT COLLISION COLLISION command? I think I can understand those better.

Thanks!
(For bearing with my countless errors)

-Sa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 14th Feb 2013 18:43 Edited at: 14th Feb 2013 19:35
Ok, I think i told you wrong. Sorry, I was hoping someone would jump in here...

INTERSECT OBJECT returns the distance between your moving object and the point of collision with the target. I thought it was a 0/1 flag but that's not the case.

In other words, it tells you you how far you have to go until impact.



OBJECT COLLISION should work as long as you're not moving your object a greater distance than the size of your target.

12000 seems like quite a 'leap' for any program, IMO.

D.D.
pcRaider
19
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 14th Feb 2013 19:33
Quote: "
Is there any way I could use something like a IF OBJECT COLLISION COLLISION command? I think I can understand those better.
"


here
SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 20th Feb 2013 17:31
Hello Again...
Because of certain complications I have decided to change part of our game.
Now, I have a few questions....

1- Is there some sort of process that i could use to find the coordinates for the object collision box?

2- I have a statement as follows:

The problem is that it will not show the PRINT "HELLO"

-Sa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 21st Feb 2013 18:39 Edited at: 21st Feb 2013 18:47
Quote: "Is there some sort of process that i could use to find the coordinates for the object collision box?"


How are you getting the coordinates to make the box in the first place? Wouldn't it be the same?

Also, I don't know why you're using static collision boxes with your objects, but (in case you didn't know already) a collision box/sphere is already generated when you make an object.

Use SHOW OBJECT BOUNDS to see them for yourself.


Quote: "The problem is that it will not show the PRINT "HELLO""


Try using SET CURSOR before your print statement.

D.D.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Feb 2013 19:17
Hi there.
I personally use sparky's collision, but I made my own intersect collision time ago. As Derek Darkly said, you need more than one intersect check for a good collision, ...I use five..front,back ,left ,right and one or two to stand on any surface. This is a good collision if we don't want to use plugins. You can implement this piece of code, to check your head...it shows basically how it works. I hope this code can help you.



I'm not a grumpy grandpa
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 21st Feb 2013 19:20
@SS45

There are many ways to check if a character has entered an area in a map. Judging by your registration date and the nature of your code you might be just getting started with DBP.

This kind of thing is extremely easy to do, but what can make it difficult is if you do not allow yourself to have things done for you; by checking what is available for you to use; what buttons you can push.

You could have solved the problem in a few moments if you looked up examples on character collision or box triggers in the search results.

You could also use Matrix1 utilities and simply establish a zone and check if the character is in it using something along the lines of; If Zone( CharacterX, CharacterY, CharacterZ ) = ZoneID Then DoAction or what ever you wanted to do.

Any basic need that most 3D games require, such as character location checks, will likely have an easy solution put together in a snippet or plugin somewhere; (Except anti-aliasing annoyingly)

Login to post a reply

Server time is: 2026-07-08 19:18:52
Your offset time is: 2026-07-08 19:18:52