Hi, we are doing space 3rd person shooter, and i hope we could get some help here.
First question:
How do we get inertia to our player, and enemies?
So if ship is flying forward but then direction is changed it should continue to fly in the old direction for a few seconds.
player has character controller and rigidbody.
Character controller has basic directions and rotation angle.
Perhaps it’s possible to use AddForce for inertia somehow.
But how do we get needed vector?
thanks
Well, it sounds to me like you don’t want to use a character controller at all, you want to use a rigidbody.
In space, there is no friction. Objects only travel in straight lines through space. Objects that do not seem to travel in straight lines are actually traveling straight along a curved surface (space).
As such, your momentum will never cease until another force is exacted equal and opposite to your original momentum.
Really all you have to do, is turn the object, and the constant force will take over, beginning to apply angular momentum in a different direction.
we have planetary battles, and you still have engines to stop you in space, because there is no friction or other way to stop. And every deceleration needs time.
That’s what I want to simulate.
And thanks for advice using rigidbody, got it working now.
But now i don’t have any colliders and if i add some to rigid body or it’s component - it’s behaving strangely when is hited by bullet wich is rigid body as well.
How so is it acting strangely? Is it transferring momentum according to newtonian physics?
If this is strange to you, I’m quite sure you should be picking up a high school physics textbook. =D
However, I see absolutely no reason to add a rigidbody to a bullet, or a missile in just about any videogame. I’d suggest a simple mesh collider and a manual implementation of a character controller. For the most part, it’s a simpler approach, and you won’t have to worry about it adding angular velocity to anything it were to hit.
i’m quite sure i’m better in newtonian physics then you ))
rigid body with no collider works really well, with right momentum, inertia, drag and so on…
But if collider is attached to Player witch is group of player components, it starts behaving strangely.
Jumping and whirling around the scene without even hitting something is strange enough for me.
That’s because a rigidbody functions as a collider.
Your collider and rigidbody are colliding with each other, and each time they try to repel each other, they move the player object, thus themselves, never fixing the problem.
You need to remove one or the other, or if you have some sensible reason for having multiple colliders, you need to make them ignore each other.
It’s my suggestion that you actually retool your rigidbody, and remove the collider.
the reason why i made a collider for rigidbody is that my rigbody is not colliding with game objects in the scene for some reason.
But IgnoreCollision is good advice, thank you.
Another thing to consider if something as small as a bullet is disrupting the path of something as large as a ship… are the relative masses of the two bodies sane?
Ok, now i’m making a sort of laser gun, and having problem with applying damage.
I have this code in Update function of my laser beam.
Target is a rigidbody with attached collider. Target’s script has ApplyDamage function.
All my weapons, like bullets, and missile explosions works using collision.rigidbody.SendMessage(“ApplyDamage”, damage)
But for some reason this code is not working with Linecast
function Update ()
{
var lineRenderer : LineRenderer = GetComponent(LineRenderer);
var dist = Vector3.Distance(aimTarget.transform.position, transform.position);
lineRenderer.SetPosition(1, Vector3(0,0,-dist));
if (!Physics.Linecast (transform.position, aimTarget.transform.position, hit)) {
print ("hit");
//Instantiate(hitEffect, hit.point, Quaternion.identity);
hit.rigidbody.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
}
}
What does that mean?
the script is instantiating a missile like this:
var bullet = Instantiate(bulletPrefab, gameObject.Find("seekingMissile_launcher").transform.position, transform.rotation);
It’s not a fatal error but it’s really annoying.
You have a component on the Object that has had its script removed. Check your prefab and remove/reattach the script. 
I’ve double checked all components attached to the prefab, and nothing is missing…
some kind of bug?
edit—
sorry, script attached to a children object of the prefab was missing.
any ideas how to make this kind of effect?
(fog with sun shafts)
Ok, i could enable a fog, add a few layers of particle clouds, and so on, but as I know sun shafts are only visible when camera is looking at a light source.
Is there any way to do a volumetric light? Or do i need to use lots of planes with alpha?
You might want to check out the godrays effect demonstrated in this thread.
PROBLEM SOLVED
Hello!
Some help with GUI needed.
One question: why this one is not working?
enum MainMenuState
{
IDLE,
WEB,
SHIPS,
GUNS,
CONFIGS,
QUIT,
}
class ManeButtons extends MonoBehaviour{
static var visible : boolean;
var explosion : Transform;
var toolbarInt : int = 0;
var toolbarStrings : String[] = ["Toolbar1", "Toolbar2", "Toolbar3"];
function Start()
{
state = MainMenuState.IDLE;
}
function OnGUI(){
var evt : Event = Event.current;
DrawGUI(evt);
}
function DrawGUI (event : Event) {
if(visible){
if (GUI.Button (Rect (156,10,50,50), "Ships")) {
state = MainMenuState.SHIPS;
//Like this :
DrawShips ();
}
}
//Or like this...
if(state == MainMenuState.SHIPS){
DrawShips ();
}
}
private var aboutScroll : Vector2;
private var aboutStyle : GUIStyle;
function DrawShips (){
Debug.Log("We are in DrawShips!");
GUILayout.BeginArea (Rect (200,200,400,100));
aboutScroll = GUILayout.BeginScrollView(aboutScroll, GUILayout.Width(400));
//and some gui elements here...
GUILayout.EndScrollView();
GUILayout.EndArea();
}
function DrawGuns (){
}
}
The problem is - I can’t get elements from DrawShip() to be visible when button is pressed. Even if log from this function can be printed.
Thanks