Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

maltoc

Member
  • Content Count

    26
  • Joined

  • Last visited

Community Reputation

0 Neutral

About maltoc

  • Rank
    Member

Profile Information

  • Location:
    France
  1. maltoc

    New UI JS problem

    It's work thanks for your help
  2. maltoc

    New UI JS problem

    Now i have this : NullReferenceException: Object reference not set to an instance of an object player.Update () (at Assets/scripts/player.js:19) so : Checkpoint.text = "Checkpoint: " + currentCheckpoint; and the same for Lap.text = " lap: " + currentLap; in my canvas i have a text call Lap and other Checkpoint on the inspector .
  3. maltoc

    New UI JS problem

    yes for checkpoint it's work but no i have player.js(14,35): BCE0022: Cannot convert 'UnityEngine.Component[]' to 'UnityEngine.UI.Text'. so the Lap = gameObject.GetComponents(Text); but it's the same of the checkpoint what i need to do ? and thanks for your help =D
  4. maltoc

    New UI JS problem

    Hi, so i make a racing game and i have found a script for laps and checkpoint so i have modified this script but whith the new UI there are some bug error : player.js(13,40): BCE0022: Cannot convert 'UnityEngine.UI.Text' to 'System.Type'. player.js(14,36): BCE0022: Cannot convert 'UnityEngine.Component[]' to 'System.Type'. player.js(19,13): BCE0019: 'text' is not a member of 'System.Type'. player.js(20,6): BCE0019: 'text' is not a member of 'System.Type'. and this is the script player : #pragma strict import UnityEngine.UI; var checkPointArray : Transform[]; //Checkpoint GameObjects stored as an array static var currentCheckpoint : int = 0; //Current checkpoint static var currentLap : int = 0; //Current lap static var startPos : Vector3; //Starting position private var Checkpoint = Text; private var Lap = Text; function Start () { Checkpoint = gameObject.GetComponent(Text); Lap = gameObject.GetComponents(Text); startPos = transform.position; //Store the starting position of the player } function Update () { Checkpoint.text = "Checkpoint: " + currentCheckpoint; Lap.text = " lap: " + currentLap; } i have try to add import UnityEngine.UI.Text; but don't work So if you no thanks for your help .
  5. maltoc

    Altitude problem

    It's work thanks you very much
  6. maltoc

    Altitude problem

    yes but i need the gravity so i need a rigidbody i think no ? i want the gameobject fall but when i use the gaz they up but when i up at 125 approximately they stop and fall and when i use gaz they don't up . and when i touch the ground i can up but it's a bug i think .
  7. maltoc

    Altitude problem

    hi, i have a problem with unity i have my player who take altitude in Y axis en when he is on 125 he slow and fall and when he fall i can't up like a airplane and whe need to wait he touch the groun to take the control so i try to find the problem with modify the rigibody but they don't work,next i try with the physic manager but don"t work . i have thinking they from by my mesh so i try with a cube but don't change so maybe they come from my script ? var centre_drone : GameObject; var ONOFF = false; var GY = 5; //gaz var DY = 5; //pencher avant var DX = 5; //rouler a droite gauche var GX = 5;//rotation suur lui meme function FixedUpdate(){ centre_drone.transform.Rotate(Vector3(Input.GetAxis("Vertical2")*DY,0,0));//pencher avant/|/arriere centre_drone.transform.Rotate(Vector3(0,0,Input.GetAxis("Horizontal2")*DX));//rouler droite/|/gauche centre_drone.transform.Rotate(Vector3(0,Input.GetAxis("Horizontal"),0*GX));//rotation sur lui meme centre_drone.transform.Translate(Vector3(0,Input.GetAxis("Vertical"),0*GY));//gaz } i don't no where they come from so thanks to you to help me .
  8. maltoc

    Network ViewID same

    Ok so i do a script name NetworkUser placed on the player : #pragma strict function Start () { if (this.networkView.isMine) { gameObject.GetComponent(fly).enabled =true; gameObject.GetComponentInChildren(Camera).enabled =true; gameObject.GetComponent(altimeter).enabled =true; gameObject.GetComponent(nitro).enabled =true; gameObject.GetComponent(RotateY).enabled =true; gameObject.GetComponent(looping).enabled =true; gameObject.GetComponent(canon).enabled =true; gameObject.GetComponent(canon).enabled =true; gameObject.GetComponent(Missile).enabled =true; gameObject.GetComponent(healthBar).enabled =true; gameObject.GetComponent(MeshRenderer).enabled =true; gameObject.GetComponent(BoxCollider).enabled =true; gameObject.GetComponent(MeshCollider).enabled =true; } } and in my playercontroller they still function Start (){ if(Network.peerType == NetworkPeerType.Client || Network.peerType == NetworkPeerType.Server); if(networkView.isMine == false){ gameObject.GetComponent(fly).enabled =false; gameObject.GetComponentInChildren(Camera).enabled =false; gameObject.GetComponent(altimeter).enabled =false; gameObject.GetComponent(nitro).enabled =false; gameObject.GetComponent(RotateY).enabled =false; gameObject.GetComponent(looping).enabled =false; gameObject.GetComponent(canon).enabled =false; gameObject.GetComponent(healthBar).enabled =false; } } so when i launch the server and i spawn all work but the 3Dmodel don't appears . and i have this error : View ID AllocatedID: 1 not found during lookup. Strange behaviour may occur
  9. maltoc

    Network ViewID same

    i have do that in my player control : function Start (){ if(Network.peerType == NetworkPeerType.Client || Network.peerType == NetworkPeerType.Server); if(networkView.isMine == false){ gameObject.GetComponent(fly).enabled =false; gameObject.GetComponentInChildren(Camera).enabled =false; gameObject.GetComponent(altimeter).enabled =false; gameObject.GetComponent(nitro).enabled =false; gameObject.GetComponent(RotateY).enabled =false; gameObject.GetComponent(looping).enabled =false; gameObject.GetComponent(canon).enabled =false; gameObject.GetComponent(healthBar).enabled =false; } } i need to change that at true and in the function start of my network master i add a system who check the id of the network view or i do that in the playercontrol ? with the script at top ? if you can explain to me properly you can add me on skype ? tell me in private message and i take 10 min of your time to explain to me all my mistake . edit : i try to start from the beginning i have a new error : View ID SceneID: 1 Level Prefix: 0 not found during lookup. Strange behaviour may occur Received state update for view id' SceneID: 1 Level Prefix: 0' but the NetworkView doesn't exist ms_IDToPointer->find (obj->GetInstanceID ()) == ms_IDToPointer->end ()
  10. maltoc

    Network ViewID same

    Yes maybe but in single player i can do everything i want to do so this is why i try to do multiplayer but maybe i can retry all the network and not copy something i don't no but i thinks i be block in the same script so i search what i need to do ? if i change the networkrigidbody in javascript and add the script of nub it's that can be done ? or maybe i can use photon because there are a lot of tutorial ? like this youtube video : https://www.youtube.com/playlist?list=PLbghT7MmckI7BDIGqNl_TgizCpJiXy0n9 i just change the party of FPS in the party of third person control a airplane and it's good no ?
  11. maltoc

    Network ViewID same

    So i try but the problem is the networkrigidbody is my only script in C# the other is in javascript so when i change the playercontrol by the script of the control of my player they don't found the script . i need to do myself the networkrigidbody in javascript to work or i need to change all in C# ? or is something else ?
  12. maltoc

    Network ViewID same

    I don't use photon network i use the native network of unity so i don't no if it's work ?
  13. maltoc

    Network ViewID same

    Hello,i'm here because i have a problem with my script . when the player create a server it's good but when someone connect to the player there control the same prefab , the prefab have a network view component and is connected to a script C# i have fund for the interpolation this is the code : using UnityEngine; using System.Collections; public class NetworkRigidbody : MonoBehaviour { public double m_InterpolationBackTime = 0.1; public double m_ExtrapolationLimit = 0.5; internal struct State { internal double timestamp; internal Vector3 pos; internal Vector3 velocity; internal Quaternion rot; internal Vector3 angularVelocity; } // We store twenty states with "playback" information State[] m_BufferedState = new State[20]; // Keep track of what slots are used int m_TimestampCount; void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { // Send data to server if (stream.isWriting) { Vector3 pos = rigidbody.position; Quaternion rot = rigidbody.rotation; Vector3 velocity = rigidbody.velocity; Vector3 angularVelocity = rigidbody.angularVelocity; stream.Serialize(ref pos); stream.Serialize(ref velocity); stream.Serialize(ref rot); stream.Serialize(ref angularVelocity); } // Read data from remote client else { Vector3 pos = Vector3.zero; Vector3 velocity = Vector3.zero; Quaternion rot = Quaternion.identity; Vector3 angularVelocity = Vector3.zero; stream.Serialize(ref pos); stream.Serialize(ref velocity); stream.Serialize(ref rot); stream.Serialize(ref angularVelocity); // Shift the buffer sideways, deleting state 20 for (int i = m_BufferedState.Length-1; i >= 1; i--) { m_BufferedState[i] = m_BufferedState[i-1]; } // Record current state in slot 0 State state; state.timestamp = info.timestamp; state.pos = pos; state.velocity = velocity; state.rot = rot; state.angularVelocity = angularVelocity; m_BufferedState[0] = state; // Update used slot count, however never exceed the buffer size // Slots aren't actually freed so this just makes sure the buffer is // filled up and that uninitalized slots aren't used. m_TimestampCount = Mathf.Min(m_TimestampCount + 1, m_BufferedState.Length); // Check if states are in order, if it is inconsistent you could reshuffel or // drop the out-of-order state. Nothing is done here for (int i=0;i<m_TimestampCount-1;i++) { if (m_BufferedState[i].timestamp < m_BufferedState[i+1].timestamp) Debug.Log("State inconsistent"); } } } // We have a window of interpolationBackTime where we basically play // By having interpolationBackTime the average ping, you will usually use interpolation. // And only if no more data arrives we will use extra polation void Update () { // This is the target playback time of the rigid body double interpolationTime = Network.time - m_InterpolationBackTime; // Use interpolation if the target playback time is present in the buffer if (m_BufferedState[0].timestamp > interpolationTime) { // Go through buffer and find correct state to play back for (int i=0;i<m_TimestampCount;i++) { if (m_BufferedState[i].timestamp <= interpolationTime || i == m_TimestampCount-1) { // The state one slot newer (<100ms) than the best playback state State rhs = m_BufferedState[Mathf.Max(i-1, 0)]; // The best playback state (closest to 100 ms old (default time)) State lhs = m_BufferedState[i]; // Use the time between the two slots to determine if interpolation is necessary double length = rhs.timestamp - lhs.timestamp; float t = 0.0F; // As the time difference gets closer to 100 ms t gets closer to 1 in // which case rhs is only used // Example: // Time is 10.000, so sampleTime is 9.900 // lhs.time is 9.910 rhs.time is 9.980 length is 0.070 // t is 9.900 - 9.910 / 0.070 = 0.14. So it uses 14% of rhs, 86% of lhs if (length > 0.0001) t = (float)((interpolationTime - lhs.timestamp) / length); // if t=0 => lhs is used directly transform.localPosition = Vector3.Lerp(lhs.pos, rhs.pos, t); transform.localRotation = Quaternion.Slerp(lhs.rot, rhs.rot, t); return; } } } // Use extrapolation else { State latest = m_BufferedState[0]; float extrapolationLength = (float)(interpolationTime - latest.timestamp); // Don't extrapolation for more than 500 ms, you would need to do that carefully if (extrapolationLength < m_ExtrapolationLimit) { float axisLength = extrapolationLength * latest.angularVelocity.magnitude * Mathf.Rad2Deg; Quaternion angularRotation = Quaternion.AngleAxis(axisLength, latest.angularVelocity); rigidbody.position = latest.pos + latest.velocity * extrapolationLength; rigidbody.rotation = angularRotation * latest.rot; rigidbody.velocity = latest.velocity; rigidbody.angularVelocity = latest.angularVelocity; } } } } so this script is in the prefab player . i use a function start when the player load the level this is the script : var player : Transform; function Start (){ Network.Instantiate(player, transform.position, transform.rotation, 0); } and in the menu i use this function : function OnServerInitialized() { // le serveur a ete crée Debug.Log ("serveur crée et jouable"); Application.LoadLevel("nivtest"); } function OnConnectedToServer () { Application.LoadLevel("nivtest"); } so i don't no where is my error and what i need to do . ps : this is the error : view ID allocated Id not found during lookup.Strange behaviour may occur Received state update for view ID but the networkview doesn't exist Thanks you to read this and i'm sorry for the error in english i'm french and i don't speak very good english . Cordially maltoc
  14. How did you do thas ? Sorry but i learn unityscript .
  15. Vector 3 change nothing . Danny i just need to change in the spawnpoint script SpawnPoint.position to Players.position ?
×
×
  • Create New...