Trouble with FPS Tutorial 1

I am working through the FPS Tutorial, and have run into one snag and one anomoly.

The snag is from 7. Missle explosions.

In step 4. “Finally, we want…” the two user steps are:

What this is trying to do is add a javascript that detects the first collision of the object “missile” and calls an explosion animation at the contact point, and then destroys the object “missile”.

What I find is that, dragging and dropping the javascript onto the prefab object “missile” in the PROJECT view doesn’t work. I find that if I drag the prefab object “missile” into either the scene SCENE VIEW or HIERARCHY windows, it will successfully attach after warning me that Losing prefab This action will lose the prefab connection. Are you sure you wish to continue?”. This also causes an iteration of the object “missile” to instantiate in the game world, which should not be the case for the missile.

I’ve re-read the tutorial, and searched the forum, and no one seems to have had the same problem. How can I create a missile prefab and attach the javascript to it without bringing it into the scene/world?

What am I missing? My brain, prolly…

The anomoly:

I find that in the previous step, 6. Adding a weapon, that when I follow the steps and create this tennis ball “launcher” (yes, I did have to texture them bright yellow), that when I use it within the tutorial environment that the “missile” objects do not consistently collide with objects or surfaces on the tutorial geometry. About half the time, they just pass through the surface plane of any given object. This seems to be something related to the vector of the “missile” object. If I don’t move, the behaviour of the “missile” object is consistent, but if I move the view and fire again, the “missile” object may bounce against a surface, or it may not. In on given position/view/vector, the “missile” object will always bounce, or always pass through the plance it hits. Moreover, each surface is independent. If it bounces off the floor, it may (or may not) then pass through a wall or one of the other objects in the scene. I’ve seen some balls go through a “container” object, pop out the other side, and then bounce along the ground and roll off the edge into the void.

Tho’ts? Suggestions?

You could rise the frequency of fixed updates.
Read this topic: http://forum.unity3d.com/viewtopic.php?t=3675&highlight=frequency

For the first problem, you’ll want to modify the prefab directly rather than in the scene. Click on the prefab so it appears in the inspector panel, then you can add the script from there by dragging the script onto that panel.

LKA:

Thanks for the tip. I suspected something along those lines. I haven’t found the parameters I’m looking for to adjust this yet, but I am sure I’ll figger it out. It’s a subject not covered under the tutorial, so I’ll do a little digging. For the purposes of the Tutorial, the fact that the tennis ball “grenades” fall thru the geometry doesn’t invalidate what I’m learning.

StarManta:

I tried to modify the prefab in the PROJECT window, but the script won’t take. The only way I can get the prefab to accept the script is when I drag it into the HIERARCHY or the SCENE VIEW window, but this defeats the purpose. The javascript seems to be valid, because when I do attach the script in the HIERARCHY window, the one pre-instantiated ball falls out of the sky when I run the scene, and it explodes on impact.

That being said, when I save the script, I do get an error in the bottom bar that reads:

This variable is in the tutorial script, but it does seem to dangle and doesn’t seem to get referred to.

This is what I have typed in, and I can see no errors compared to the script in the tutorial.

This is what the “missile” object PreFab is set up to be:

This is the java script as it sits in the INSPECTOR window:

As I type this I want to say that I’ve followed the instructions in the manual exactly, but I realize this is not true. I’ve made two modifications. ONE is to reduce the size of the sphere to 0.15 on all dimensions (to tennis ball size), because the default sphere is huge. (This could account for why my tennis ball grenades fall through the geometry.) I addded a texture to the sphere and changed the colour to make them yellow. I wouldn’t imagine this could be a problem, but for troubleshooting purposes, I thought I’d mention it.

Any ideas?

Just to make sure, I went back and rebuilt the missile to tutorial spec from the ground up: No Resize and No Texture, and it still won’t attach unless I put it in the HIERARCHY window.

THANKS for ALL YOUR SUPPORT!

I had restarted the .app, and that didn’t do anything. So - on a whim, I restarted the machine, and now the script attaches properly.

_<

Sorry for wasting your time, but now I’m stuck on the next step: See “Trouble with FPS Tutorial 1 # 2”.

[snip]/projectile.js(9) warning BCW0003: Warning: Unused local variable ‘instantiatedExplosion’.

that’s just a warning. won’t hurt much :smile: it’s just declared but never used which wastes space.

losing a prefab connection isn’t a big deal either. only matters if you want those changes to be used in the prefab. if you do, do it in the project view instance like starmanta said or update the prefab later (before you use it).

objects going through other objects is usually because they passed through between physics time steps. typically because the geometry is too small or like lka said, the timestep is too small. you can set the timestep in project physics settings.

Pete:

Thanks for driving instructions!

I had the same problem exactly. I could not attache the script on the prefab in the ProjectView. Restarting the machine didn’t help at all. However, while I was going on with the tutorial I found out that I could attach the script by having selected the prefab in the project view and go from the menu to Component>scripts and select from the list the scrit “projectile” I created before for the missile. and after that, I felt soooo stupid :roll:

You should be able to drag components (in this case scripts) onto the pipeline tab in the inspector view, when the prefab is selected in the project view. Im guessing thats what it was designed for?

Where theres a Unity editor, theres a way…
AC