Raycasts on iPhone: Tutorials

Hi Guys,

I’ve been struggling with raycasting on the iPhone for ages now and was wondering if anyone knows of any links to tutorials, articles, or forum threads that cover the topic. The unity scripting manual is a very handy reference (I love being able to search it from the top left search box :slight_smile: ) and the forums are a GREAT place to pick up knowledge on all topics, but I’m just not getting by with whats in either place. I do have some raycasting working but I’m worried that its messy inefficient and for stuff like casting rays against specific colliders in a scene (which is something I’ll need) I’m totally in the dark. I hope the information is just somewhere I keep missing in my searches!

Over to you guys, any ideas?

Thanks!

I wouldn’t mind hearing more about this as well. I seem to have some bugs in this area recently. :slight_smile:

What exactly do you guys want to know?

You can specify a layer mask to only test for certain colliders.

There’s nothing iPhone-specific about raycasting, so I doubt this is the best forum.

–Eric

The unity manual has quite a few good pieces of code in it on this. But it sounds like you’re looking for (off the top of my head) if (hit.collider.name == “awesomeCollider”)

There are more optimised methods, but that’s probably what you’re looking for :slight_smile:

Thanks for the replies guys, your all kind of in the right area, to sum up what I’m looking for is actual code examples of raycasting on the iPhone, or in general as Eric5h5 points out its the same for general unity use. I could read and under stand theory all day long but to be actually able to code I’d need to see example code, that’s just the way I am :wink:

Smag, you said

could you give a snippet of code to show this working by any chance? I know its possible to do stuff like this, its just getting the right code example so I can solidify in my mind for use is my problem, once I get it working the first time then I’m set for life, as it were :slight_smile:

And JTBentley, your code :

is exactly the kind of thing I’m looking for examples of, for example, how would I use methods like Physics.Raycast, Collider.Raycast and RaycastHit? these are all in the doc’s in the same topic area but I’m not sure when and where to use what :?

Having said all that I definably think that I’m getting way better and confident on this topic, again, thank you to all involved! :smile:

Perhaps if everyone was to put up snippets of code they think is relevant and explains something, might be a better way of getting the knowledge out there? I’ll put up the limited stuff I have when its working better and I’m confident that its the right way of doing what I’m trying to do, I don’t want to put out mis-information!

There should be sufficient example code in even the basic iPhone packages?

Just download some of the example projects, it’s all in there :slight_smile:

There is code and it is useful, just for specific code examples of different ray casts I’d love an actual example. Having said all that I’m getting by with what I know and getting much better at it. Think I’ll press on and if I come up with a specific problem, post the question here :idea:

Crazy,

I’d not hold your breath my friend. The only guys who ever stick there nose into threads requesting such instruction are the folk that don’t need it and don’t plan to write it. They just wander in to let you know you’re a dumb ass for asking.

I on the other hand, recently emboldened by the prevailing “check out the examples, its all in there” theorem of efficient learning have undertaken a vigorous educational campaign. I’ve been writing to companies like Gnomon Workshop, Digital Tutors and that other misguided band of slackers at Lynda.com to let them know that, a good reference manual and example files come with Maya, Houdini, Real Flow, Nuke and such. Why would they consider developing additional learning resources for programs that already “have it all in there?” weird, huh?

B.

P.S There was once a merry band of folk here called the ‘demo-team’. They have unfortunately since been cut up and sold for parts to hire the other various ‘heavyweights’ that were so sourly needed. Go team…

All I see here is people trying to point him in the right direction. Off course nobody wrote a tutorial for him, but who’s got time for that? But no one is calling anyone dumb here.

On the surface, you make a valid observation. Yet, it assumes that Crazy did not look through the reference guide, the examples, the available training material and still find the need for specific training examples. I, and if you look through the numerous other similar threads, have made such inquires before, only to be told, that I and others don’t need em.

I assume Crazy is not a feckless chimp, knows exactly what he his asking for, and wrote clearly in his posts. Might one take the position that telling him he already has all the material he needs imply that he is in fact a dumbass?
Not necessarily, but you can’t rule it out.

There are many ways to learn and to ‘know’ things. Henry Ford for example was being interviewed once by a group of reporters about various technical facets about his automobile and the internal combustion engine. Frustrated by the tone and randomness of the questions, he cleared his throat and in a sharp voice explained to the reporters that on his desk was a box with a series of buttons. If he needed a fact about a specific something he simply hit a button, and someone came up to his office and explained what Ford wanted to know.

Some of us want to tinker endlessly with code and know it all ourselves. Some, invest in 3rd party training and absorb years of knowledge and tinkering in a compressed time-line. There are multiple 3rd parties who frequent this board who are industrious and helpful, such as Alec at Infinte Ammo or have an entrepreneurial take such as Mike at UnityTutorials.com. In these cases, posting for specific topics, areas of interest or even broader learning material makes perfect sense. With that being the intention, to have someone come into one’s thread, tell them that they don’t require any additional training material could be a tad presumptuous. Would you not agree?

On the more guy to guy level… Are there actually grown men who get flustered when another guy barks about something he’s not thrilled about? Seriously? I have no idea where they work, but most production shops are a bit rough and tumble to put it mildly. To appear put-off, tweaked, insulted, hurt or otherwise, when someone flexes a lil attitude seems disingenuous. Unless I really did hurt your feelings. In which case, gosh I’m so sorry.

B. :wink:

Just trying to undestand where you were coming from with that comment. It seemed a bit random to me, but now I guess you do have a point.

Thanks. I think we all just want to know enough to make good product, pay the team and our mortgage, maybe buy beers and pizza on Fri nights.

later,
B.