Jump to content

The flashlight effect


Recommended Posts

Posted

I'm trying to create a plug-in with a flashlight effect so that the light turns on in front of the player in the same way he would hold a flashlight on, but nothing works.

My experiments led me to a fireball, which I can create on command.

        [ChatCommand("spawnfire")]
        private void SpawnFire(BasePlayer player, string command, string[] args)
        {
            Vector3 basePosition = player.transform.position + player.eyes.HeadForward() * 2f;
            
            float groundHeight = TerrainMeta.HeightMap.GetHeight(basePosition);
            
            Vector3 position = new Vector3(basePosition.x, groundHeight + 1.0f, basePosition.z);

            var fireball = GameManager.server.CreateEntity("assets/bundled/prefabs/fireball.prefab", position) as FireBall;
            if (fireball != null)
            {
                fireball.Spawn();

                timer.Once(20f, () =>
                {
                    if (fireball != null && !fireball.IsDestroyed)
                        fireball.Kill();
                });

                player.ChatMessage($"Fireball generated: {position}");
            }
            else
            {
                player.ChatMessage("Error: failed to create fireball.");
            }
        }

But apart from fireballs, nothing works. I've already tried about a hundred prefabs. Is there a glow effect prefab that can do this, or is it impossible at all?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
1.9m

Downloads

Total number of downloads.

9.2k

Customers

Total customers served.

134.1k

Files Sold

Total number of files sold.

2.8m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.