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.

Dark GDK .NET / moving an object...

Author
Message
xix psycho xix
15
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 27th Oct 2010 16:16
Ok, I have another small problem. I am trying to simulate a bullet object by the following code:



the bullets fire and update fine, but the problem is the way they move. I am trying to make them fire directly away from where my camera is pointing but they always seem to fire in the same direction regardless of where the camera is pointing. Anyone have a suggestion?
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 27th Oct 2010 20:08
The problem looks like it is here...

pellets[1].SetOrientation (cam);
pellets[1].Rotate (1.0f, -1.0f, 0.1f);


You are setting the angle of the object to the camera angle but then reset it to (1, -1, 0.1) right after. Try just shifting those 2 commands around, the rotate should be first and the set orientation should be second.

xix psycho xix
15
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 28th Oct 2010 00:21 Edited at: 28th Oct 2010 00:22
oh no actually i did that so that one of the two pellets would travel in a different direction, simulating a shotgun pattern. The problem is that neither of them fire in any way close to the way the camera is facing unless the camera is facing the way it does when the game starts. Yeah i did that so that one would kinda stray away from the other one while they were flying.

actually this behavior works correctly, both fly in almost the same direction, it is just they originate from the wrong point.
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 28th Oct 2010 08:08
Yeah but the problem is your setting them to a set position which disregards the positioning in terms of the camera. The way it currently is you don't even need the command to set it the orientation of the camera because you reset it imediatly after to that fixed angle.

If you want that slight deviation you need to take into account the current angle of the object and then subtract/add a minor value.

not exatly sure what the .Net code is for it but in GDK it would look something like this.

dbRotateObject(obj, dbObjectAngleX(obj)+1, dbObjectAngleY(obj)-1, dbObjectAngleZ(obj)+0.1);

That way you use the current angle and then adjust slightly so you get what your looking for, the way you are currently doing it you just set the angle to X:1 Y:-1 Z:0.1 every time.

When you roate it isnt adding/substracting from current values it is just setting it to that number. So if you told it Y rotate 90 it would be facing right, if you did that again it would still be facing right and would not be 180 total.

xix psycho xix
15
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 28th Oct 2010 19:34
Oh yeah i see what you mean. Now I get that one of them will be traveling in the wrong direction but why is the other one that I do not turn doing that?
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 28th Oct 2010 20:58
Well from the looks of it you never do anything with the first one [0] and only rotate the 2nd one [1], so it was more of a conicidence that it was working properly aside from the fact that they were not going were the camera was facing. As it is right now when you make the first one it is just pointing with the default angle 0,0,0 so you need to set that to your cameras angle if you want it to go straight from the camera and then do the same with the 2nd bullet only with that you are changing the angle slightly to get the deviation.

xix psycho xix
15
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 29th Oct 2010 06:20
yeah i figured out the camera angle thing. I just used the current angles of the camera to point the objects where I wanted them to go. Thanks for all ur help. Now I just have to put it all together.

Login to post a reply

Server time is: 2024-04-24 11:21:50
Your offset time is: 2024-04-24 11:21:50