How can i make my bullets (that skip 3 feet every frame)… um. well… not. do that. y’know? not do that.
Don’t have them going so fast :lol:
hahahahahahahahahahahahahahahahahahahahahahahahahahahaahahahahahahahahahahhahahahahhahahahhahaahahhahahahahahhahhahaaaaaaahahhahahhahahhaahahhahahahhahahahahhahahahhahahahahh!
raycast?
what is raycast?
Search the docs. I have been using unity 1.5 yeas and havent fully understood raycasting yet. Its used by the machinegun script iirc.
The docs are really well written, as are the tutorials. You should look at them, do them, and if its still way over your head, theres this other game engine called talk, (at garagegames.com). You might find that pipeline easier? Or do a search for game engines to try a few out. Theres more than one way to free a civet.
Why dont you google that too?
Thats all from me, untill you do the above, and demonstrate that you are making an effort. Most people try to learn programming by doing courses reading books etc outside of this forum…The art of making a game takes effort on your own part. You gotta master the crawl before you can run.
AC
:? :shock: :o
:?
wow, was that ac getting frustrated by the banter?! never thought i’d see that!
dear samus, samus aran, the big t man is right (except i doubt the talk pipeline is easier ). i see the force is strong within you but you are not a master yet, young jedi. so nuff with the blabbin bout the matrix and get reading! here’s some of the scoop to get you started…
hehe ifrog summed it up well! but i’ll expand… it depends on what you’re doing. if you’re using something like this in update:
transform.postion = Vector3.forward * 3;
then Time.deltaTime is your friend. what it does is take into account the time that has past since the last frame. so…
transform.postion = Vector3.forward * 3 * Time.deltaTime;
means 3 * .01 or whatever the time change has been since the last frame because update executes every frame. in that example, .01 means you’re running at 100 frames per second. if Time.deltaTime = 1.0, then one second has past (and you’re getting 1 fps which would be bad! but i digress…). the significance of using Time.deltaTime is that now your code is not dependent on frame rate. it will move a fraction of 3 per frame and will equal 3 per second no matter what frame rate the game is running. moral of the story: if you multiply by Time.deltaTime in update, your bullet will move 3 per second instead of 3 per frame.
also a side note, unity uses meters. so the above would be 3 meters per second.
but even better, you can specify a variable.
var speed = 3.0;
transform.postion = Vector3.forward * speed * Time.deltaTime;
now you can adjust speed in the inspector and not have to recompile your script every time you tweak speed. woot!
if you’re using something in fixedupdate then check the physics timestep in your project settings (yeah in the menu, see the manual if you don’t know). among other things, this setting tells unity how often per second to execute fixedupdate. be careful though - too often and the physics engine might start slowing down performance. using a lower speed/force or the above in update might be a better solution. even the scale of your objects could come into play here. really depends on what you’re doing. more specifics might help here.
well it’s a ray that’s cast.
think of it as sending a line (ray) out in a direction that you get to specify. it doesn’t render. it really doesn’t do anything at all. unless! you ask it to tell you what it’s hit. that can give you lots of information like “i collided with something. so do damage.” or “i hit a tree and it’s 5 meters in front of me.” or “i hit an object and the pixel where i hit is the color 32,46,92.” or “i crashed into something big. send me flying backwards!” again it depends what you want to do. the do damage thing probably pertains to what you’re getting at and is a good way of avoiding missed collisions. how do you do it? rtm! it’s in the script reference under ummmm… “raycast.” still don’t get it? post another q about it… after you read and try!
peace out… i’m off to go watch stargate
the bullet would move horizotaly fore a second then stop.
This really does not mean much to me because there is no context. There could be many reasons for this. You will find you get much better help if you take time to actually post some code and then actually explain in some detail what you seem to be experiencing. Also explaining what you have tried is also very helpful.
Complex option – figure out how far your bullet moved (using Time.deltaTime etc.) and do a raycast to check the line the bullet passed through.
Simple option – give your bullet an appropriately long cylindrical collider.
hi all …
maybe it’s an old but i have the same problem here …
here is my code :
var ray = camera.ViewportPointToRay (Vector3(0.01,0.5,0));
// Do a raycast
var hit : RaycastHit;
if (Physics.Raycast (ray, hit)) {
if(hit.transform.name == "Sun"){
//do something ;
}
}
this script is work good if the hitten object is walk slowly, but when it is run quickly ( about 10 times the normal speed ) the ray didn’t see it, any help plz???
you should give your ray a range like this:
Physics.Raycast(ray, hit, 1000);
the problem is not about the distance of the ray, the problem it seems that the ray detects the object one every frame,so when depending on the frame if the object passing along the ray way between two frames it didn’t detect it , and that what happened also with the colliders, if a collider trying to move along other collider it will success sometime if the processor can’t detect the collier in a specific frame…
if there any help of this issue I’ll appreciate it
thanx all