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 Physics & Dark A.I. & Dark Dynamix / Applying Velocity in to a dynamic object in the direction the camera is faceing

Author
Message
Viroscopics
16
Years of Service
User Offline
Joined: 26th May 2007
Location:
Posted: 27th May 2007 12:54
This is the code that i have for creating the object i wish to fire and i am trying to get it to fire the same direction the camera/character controller is faceing the only problem is that i have no idea how to apply linear velocity or momentom in that fashion. I tried to base it off of the camera angle and character controller objects angel to no avail ( it's shoots all kinds of crazy directions)




Please help, I'm new to DP but see a lot of potential just need to figure out how it is supposed to work (I have gone through the help files and examples but none show it being used the way that i am looking for and haveing no luck comeing up with a decent equasion that will make camera angles work)

(well i could do it with 360 lines of code basing it off every single angle but there must be a better way)

Here I am But am not here, there you are not really there.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th May 2007 13:57
I took a look at some code I used for applying force in the facing direction. At first I messed around with directions and camera angles and all sorts of complex calculations. Then I realised you can just use the local version of the command to make something move forwards.

phy add rigid body local force
phy add rigid body local force
etc...


Viroscopics
16
Years of Service
User Offline
Joined: 26th May 2007
Location:
Posted: 27th May 2007 14:24
I'll go ahead and give it a try but in the mean time do you think that you could post a code snippet that i might be able to look over. The command documentation for DP is not nearly as good as that of DBP.

Here I am But am not here, there you are not really there.
Lance
20
Years of Service
User Offline
Joined: 22nd Jul 2003
Location: Third planet from Sun
Posted: 27th May 2007 14:50
Here is some code I use to try things out.Some of it came from the forums.

Attachments

Login to view attachments
Viroscopics
16
Years of Service
User Offline
Joined: 26th May 2007
Location:
Posted: 27th May 2007 15:11
Thank you lance, that code



sorta worked. Some reason i have to step backwards first to fire it off in front of me and if i was just moveing forward it fires behind me.

In case my movement code is needed:





return

Here I am But am not here, there you are not really there.
Lance
20
Years of Service
User Offline
Joined: 22nd Jul 2003
Location: Third planet from Sun
Posted: 27th May 2007 20:01
The code I sent works.I just downloaded it and tried it out.
Run it the way I sent it.Don't change anything..

The way the player controller and movement is setup is important.

Sorry if it's not what you were looking for.....
Viroscopics
16
Years of Service
User Offline
Joined: 26th May 2007
Location:
Posted: 28th May 2007 01:35
Well I continued to break the code up and solved my problem, The Snippet you sent does not use a character controller where the program i'm makeing does. The reason it't was have wierd fireing was because the object that i was fieing was being created within the character controller therefore applying collision physics when created. I changed the character controller size a little and the creation point ba;sed on the camera position and all is working fine now. Thank you for the nudge in the right direction.

And It was exactly what i was looking for with minor modifications.

Here I am But am not here, there you are not really there.
Lance
20
Years of Service
User Offline
Joined: 22nd Jul 2003
Location: Third planet from Sun
Posted: 28th May 2007 16:27
Thumbs up to you.


I would like to see your code in action.If you would post it...
Viroscopics
16
Years of Service
User Offline
Joined: 26th May 2007
Location:
Posted: 29th May 2007 07:42
This is the whole runnable Coda (as long as one has physics)

I still need to work on the velocity and collision code to prevent tunneling but more or less in the end i will have some decent template code.



Attached is the required media<Of course you can change that in code or copy your own over)

Here I am But am not here, there you are not really there.

Attachments

Login to view attachments
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 30th May 2007 12:11
This code was usefull to me to, so thanks.
Viroscopics
16
Years of Service
User Offline
Joined: 26th May 2007
Location:
Posted: 30th May 2007 23:02
No Problem Mr X.

Here I am But am not here, there you are not really there.

Login to post a reply

Server time is: 2024-04-20 05:22:45
Your offset time is: 2024-04-20 05:22:45