2 Errores - Help
I have this two errors can someone help me? - theres no script in the game - its a new project - with all projects i create happends the same - i alredy reinstalled unity
Assets/_CompletedAssets/Scripts/Player/PlayerMovement.cs(2,7): error CS0246: The type or namespace name CrossPlatformInput' could not be found. Are you missing a using directive or an assembly reference? using UnityEngine; using UnitySampleAssets.CrossPlatformInput; namespace CompleteProject { %|-433672157_1|% %|2078677662_2|% %|-960817400_3|% Vector3 movement; // The vector to store the direction of the player's movement. %|954322225_5|% %|139389586_6|% #if !MOBILE_INPUT %|108820483_7|% float camRayLength = 100f; // The length of the ray from the camera into the scene. #endif %|-833312685_3|% { #if !MOBILE_INPUT %|-2086315563_11|% %|-34666910_12|% #endif %|1015702605_13|% %|-778227902_14|% %|695110094_15|% %|705329995_5|% %|-1273674829_6|% %|-1381978598_7|% // Store the input axes. %|1664116609_20|% %|297344581_9|% %|477576963_22|% %|-1357247992_10|% %|2146842196_24|% %|-2143670267_5|% %|-1355795641_26|% %|-66852631_27|% %|1289392148_28|% %|705546561_29|% %|-961837370_12|% %|-1239089460_13|% %|-1277423159_32|% %|524414672_33|% %|1742129494_34|% %|-2021127989_35|% // Move the player to it's current position plus the movement. %|-1948093882_37|% %|180843283_15|% %|-2062653608_6|% %|-1423877385_40|% #if !MOBILE_INPUT %|1446350258_41|% %|-2023683103_42|% %|2071959344_43|% %|1622528017_44|% %|-2078832705_17|% if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask)) %|1083553053_47|% %|-1656574094_9|% %|903857222_49|% // Ensure the vector is entirely along the floor plane. %|1827352951_51|% %|753774082_21|% Quaternion newRotatation = Quaternion.LookRotation (playerToMouse); %|-1004717006_12|% %|-510000701_55|% %|-378024163_56|% #else %|-567826961_57|% %|1904809536_13|% %|365929813_59|% %|-928613029_12|% %|-1734112018_26|% %|552738566_27|% %|-1705560092_28|% %|769338795_64|% %|-8252477_65|% %|-2011431768_66|% %|1794584841_29|% %|1838234659_68|% #endif %|-1746828228_30|% %|451969736_70|% %|-1733310505_71|% %|627526176_72|% %|-2039333107_73|% %|2114265875_74|% anim.SetBool ("IsWalking", walking); %|229936590_76|% %|1049150749_77|% } Assets/_CompletedAssets/Scripts/Player/PlayerShooting.cs(2,7): error CS0246: The type or namespace name
UnitySampleAssets' could not be found. Are you missing a using directive or an assembly reference?
using UnityEngine;
using UnitySampleAssets.CrossPlatformInput;
namespace CompleteProject
{
public class PlayerShooting : MonoBehaviour
{
public int damagePerShot = 20; // The damage inflicted by each bullet.
public float timeBetweenBullets = 0.15f; // The time between each shot.
public float range = 100f; // The distance the gun can fire.
float timer; // A timer to determine when to fire.
Ray shootRay; // A ray from the gun end forwards.
RaycastHit shootHit; // A raycast hit to get information about what was hit.
int shootableMask; // A layer mask so the raycast only hits things on the shootable layer.
ParticleSystem gunParticles; // Reference to the particle system.
LineRenderer gunLine; // Reference to the line renderer.
AudioSource gunAudio; // Reference to the audio source.
Light gunLight; // Reference to the light component.
float effectsDisplayTime = 0.2f; // The proportion of the timeBetweenBullets that the effects will display for.
void Awake ()
{
// Create a layer mask for the Shootable layer.
shootableMask = LayerMask.GetMask ("Shootable");
// Set up the references.
gunParticles = GetComponent<ParticleSystem> ();
gunLine = GetComponent <LineRenderer> ();
gunAudio = GetComponent<AudioSource> ();
gunLight = GetComponent<Light> ();
}
void Update ()
{
// Add the time since Update was last called to the timer.
timer += Time.deltaTime;
#if !MOBILE_INPUT
// If the Fire1 button is being press and it's time to fire...
if(Input.GetButton ("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0)
{
// ... shoot the gun.
Shoot ();
}
#else
// If there is input on the shoot direction stick and it's time to fire...
if ((CrossPlatformInputManager.GetAxisRaw("Mouse X") != 0 || CrossPlatformInputManager.GetAxisRaw("Mouse Y") != 0) && timer >= timeBetweenBullets)
{
// ... shoot the gun
Shoot();
}
#endif
// If the timer has exceeded the proportion of timeBetweenBullets that the effects should be displayed for...
if(timer >= timeBetweenBullets * effectsDisplayTime)
{
// ... disable the effects.
DisableEffects ();
}
}
public void DisableEffects ()
{
// Disable the line renderer and the light.
gunLine.enabled = false;
gunLight.enabled = false;
}
void Shoot ()
{
// Reset the timer.
timer = 0f;
// Play the gun shot audioclip.
gunAudio.Play ();
// Enable the light.
gunLight.enabled = true;
// Stop the particles from playing if they were, then start the particles.
gunParticles.Stop ();
gunParticles.Play ();
// Enable the line renderer and set it's first position to be the end of the gun.
gunLine.enabled = true;
gunLine.SetPosition (0, transform.position);
// Set the shootRay so that it starts at the end of the gun and points forward from the barrel.
shootRay.origin = transform.position;
shootRay.direction = transform.forward;
// Perform the raycast against gameobjects on the shootable layer and if it hits something...
if(Physics.Raycast (shootRay, out shootHit, range, shootableMask))
{
// Try and find an EnemyHealth script on the gameobject hit.
EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth> ();
// If the EnemyHealth component exist...
if(enemyHealth != null)
{
// ... the enemy should take damage.
enemyHealth.TakeDamage (damagePerShot, shootHit.point);
}
// Set the second position of the line renderer to the point the raycast hit.
gunLine.SetPosition (1, shootHit.point);
}
// If the raycast didn't hit anything on the shootable layer...
else
{
// ... set the second position of the line renderer to the fullest extent of the gun's range.
gunLine.SetPosition (1, shootRay.origin + shootRay.direction * range);
}
}
}
}
I'm confused. You say there are no scripts in the project, but then you post a script that's obviously causing the error (because the assembly containing UnitySampleAssets can't be found). Can you clarify?
Answer by Blue-Cut · Apr 16, 2016 at 11:15 AM
Did you actually import "CrossPlatformInput" in your project ?
It 's not enough to just write "using UnitySampleAssets.CrossPlatformInput;", you need to have this in your project. Check "StandardAssets".
Assets => Import Package => CrossPlatformInput
using UnityStandardAssets.CrossPlatformInput;
I am not sure why you are dealing with UnitySamplesAssets or something but I guess the StandardAssets are what you are looking for.
When i started the project at once i had millions of errors then inported CrossPlatformInput andiit just left me that 2 errors
But why do you have using UnitySampleAssets
? If you did the importation, you probably imported CrossPlatformInput
from StandardAssets. Did you try to replace the using line by the one in my Answer.
The using line is here to find another namespace in your project. If you want to use the CrossPlatformInput
in the StandardAssets, you need to use the namespace of StandardAssets scripts :
using UnityStandardAssets.CrossPlatformInput;
Your answer
![](https://koobas.hobune.stream/wayback/20220612073907im_/https://answers.unity.com/themes/thub/images/avi.jpg)